InterviewSolution
This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
| 101. |
What are static member functions?(a) Functions which use only static data member but can’t be accessed directly(b) Functions which uses static and other data members(c) Functions which can be accessed outside the class with the data members(d) Functions using only static data and can be accessed directly in main() functionThis question was posed to me in examination.This key question is from Types of Member Functions topic in portion Member Functions & its Types of Object Oriented Programming |
|
Answer» Right CHOICE is (d) Functions using only STATIC data and can be accessed directly in main() function |
|
| 102. |
Simple member functions are ______________________(a) Ones defined simply without any type(b) Ones defined with keyword simple(c) Ones that are implicitly provided(d) Ones which are defined in all the classesI got this question in unit test.I would like to ask this question from Types of Member Functions in division Member Functions & its Types of Object Oriented Programming |
|
Answer» Right option is (a) Ones defined simply without any type |
|
| 103. |
How many types of member functions are possible in general?(a) 2(b) 3(c) 4(d) 5The question was asked in an international level competition.My query is from Types of Member Functions in section Member Functions & its Types of Object Oriented Programming |
|
Answer» Correct choice is (d) 5 |
|
| 104. |
The abstract method definition can be made ___________ in derived class.(a) Private(b) Protected(c) Public(d) Private, public, or protectedI have been asked this question during an online interview.My question is based upon Abstract Function topic in chapter Member Functions & its Types of Object Oriented Programming |
|
Answer» Right answer is (d) Private, public, or protected |
|
| 105. |
The abstract methods can never be ___________ in a base class.(a) Private(b) Protected(c) Public(d) DefaultI have been asked this question during an interview.The question is from Abstract Function in division Member Functions & its Types of Object Oriented Programming |
|
Answer» The CORRECT OPTION is (a) Private |
|
| 106. |
If a class have all the abstract methods the class will be known as ___________(a) Abstract class(b) Anonymous class(c) Base class(d) Derived classI got this question in final exam.Question is from Abstract Function in division Member Functions & its Types of Object Oriented Programming |
|
Answer» RIGHT answer is (a) Abstract class Easiest explanation - The CLASSES CONTAINING all the abstract METHODS are known as abstract classes. And the abstract classes can never have any normal function with definition. Hence known as abstract class. |
|
| 107. |
Which among the following is correct for abstract methods?(a) It must have different prototype in the derived class(b) It must have same prototype in both base and derived class(c) It must have different signature in derived class(d) It must have same return type onlyI have been asked this question during an interview.My question comes from Abstract Function topic in section Member Functions & its Types of Object Oriented Programming |
|
Answer» Right OPTION is (b) It MUST have same prototype in both base and derived class |
|
| 108. |
Which among the following is true?(a) Abstract methods can be static(b) Abstract methods can be defined in derived class(c) Abstract methods must not be static(d) Abstract methods can be made static in derived classI had been asked this question by my school teacher while I was bunking the class.The doubt is from Abstract Function topic in portion Member Functions & its Types of Object Oriented Programming |
|
Answer» The correct option is (c) Abstract METHODS must not be static |
|
| 109. |
Static methods can’t be made abstract in java.(a) True(b) FalseThe question was asked in an internship interview.This key question is from Abstract Function in portion Member Functions & its Types of Object Oriented Programming |
|
Answer» Correct option is (a) True |
|
| 110. |
If a function declared as abstract in base class doesn’t have to be defined in derived class then ______(a) Derived class must define the function anyhow(b) Derived class should be made abstract class(c) Derived class should not derive from that base class(d) Derived class should not use that functionThe question was posed to me during an interview.The question is from Abstract Function in division Member Functions & its Types of Object Oriented Programming |
|
Answer» The correct choice is (b) Derived CLASS should be made abstract class |
|
| 111. |
What is the syntax for using abstract method?(a) abstractmethod_name (parameter)(b) absmethod name (parameter)(c) abstract return-type method name (parameter)(d) abstract method name (parameter)I got this question in semester exam.This intriguing question comes from Abstract Function in section Member Functions & its Types of Object Oriented Programming |
|
Answer» Right ANSWER is (a) |
|
| 112. |
What is this feature of enforcing definitions of abstract function at compile time called?(a) Static polymorphism(b) Polymorphism(c) Dynamic polymorphism(d) Static or dynamic according to needThis question was posed to me in a national level competition.Query is from Abstract Function in division Member Functions & its Types of Object Oriented Programming |
|
Answer» CORRECT choice is (C) Dynamic polymorphism To EXPLAIN I would say: The FEATURE is known as Dynamic polymorphism. Because the definitions are resolved at RUNTIME. Even though the definitions are checked at compile time, they are resolved at runtime only. |
|
| 113. |
The abstract function definitions in derived classes is enforced at _________(a) Runtime(b) Compile time(c) Writing code time(d) Interpreting timeThe question was posed to me at a job interview.This key question is from Abstract Function topic in section Member Functions & its Types of Object Oriented Programming |
|
Answer» Correct option is (B) Compile time |
|
| 114. |
It is ____________________ to define the abstract functions.(a) Mandatory for all the classes in program(b) Necessary for all the base classes(c) Necessary for all the derived classes(d) Not mandatory for all the derived classesThis question was posed to me during an interview.I need to ask this question from Abstract Function topic in section Member Functions & its Types of Object Oriented Programming |
|
Answer» The correct option is (c) Necessary for all the derived classes |
|
| 115. |
Which among the following is correct?(a) Abstract functions should not be defined in all the derived classes(b) Abstract functions should be defined only in one derived class(c) Abstract functions must be defined in base class(d) Abstract functions must be defined in all the derived classesI have been asked this question by my school principal while I was bunking the class.The question is from Abstract Function in portion Member Functions & its Types of Object Oriented Programming |
|
Answer» The correct OPTION is (d) ABSTRACT functions must be defined in all the DERIVED classes |
|
| 116. |
How are abstract functions different from the abstract functions?(a) Abstract must not be defined in base class whereas virtual function can be defined(b) Either of those must be defined in base class(c) Different according to definition(d) Abstract functions are fasterI had been asked this question in my homework.This intriguing question originated from Abstract Function in portion Member Functions & its Types of Object Oriented Programming |
|
Answer» CORRECT OPTION is (a) Abstract MUST not be defined in base class whereas virtual function can be defined Easiest explanation - The abstract functions are only declared in base class. Derived classes have to implement those functions in order to inherit that base class. The functions are always defined in derived classes only. |
|
| 117. |
Which among the following is true?(a) The abstract functions must be only declared in derived classes(b) The abstract functions must not be defined in derived classes(c) The abstract functions must be defined in base and derived class(d) The abstract functions must be defined either in base or derived classI have been asked this question in my homework.This interesting question is from Abstract Function in portion Member Functions & its Types of Object Oriented Programming |
|
Answer» CORRECT option is (a) The ABSTRACT functions must be only declared in derived classes Explanation: The abstract functions can’t be DEFINED in BASE class. They are to be defined in derived classes. It is a rule for abstract functions. |
|
| 118. |
Which among the following best defines the abstract methods?(a) Functions declared and defined in base class(b) Functions only declared in base class(c) Function which may or may not be defined in base class(d) Function which must be declared in derived classThe question was asked by my college director while I was bunking the class.My question is based upon Abstract Function topic in chapter Member Functions & its Types of Object Oriented Programming |
|
Answer» RIGHT answer is (b) Functions only declared in base class To EXPLAIN I WOULD SAY: The abstract functions must only be declared in base class. Their definitions are provided by the derived classes. It is a mandatory CONDITION. |
|
| 119. |
If virtual function of base class is redefined in derived class then ________________(a) It must be declared virtual in derived class also(b) It may or may not be declared virtual in derived class(c) It can must not be declared virtual in derived class(d) It must be declared normally in derived classThis question was addressed to me during an online exam.The doubt is from Virtual Functions in portion Member Functions & its Types of Object Oriented Programming |
|
Answer» CORRECT OPTION is (b) It may or may not be declared virtual in DERIVED class For explanation: The virtual functions may or may not be declared virtual in derived class. This is because if the overriding function defined in derived class is not declared virtual explicitly, the COMPILER makes it virtual IMPLICITLY. |
|
| 120. |
Which among the following is true?(a) A class may have virtual destructor but not virtual constructor(b) A class may have virtual constructor but not virtual destructor(c) A class may have virtual constructor and virtual constructor(d) A class may have either virtual destructor or virtual constructorI had been asked this question at a job interview.My query is from Virtual Functions topic in portion Member Functions & its Types of Object Oriented Programming |
|
Answer» Correct choice is (a) A CLASS may have virtual destructor but not virtual constructor |
|
| 121. |
It is __________ to redefine the virtual function in derived class.(a) Necessary(b) Not necessary(c) Not acceptable(d) Good practiceThis question was posed to me in an interview.My question comes from Virtual Functions in portion Member Functions & its Types of Object Oriented Programming |
|
Answer» Correct answer is (b) Not necessary |
|
| 122. |
The virtual functions must be declared and defined in _____________ class and overridden in ___________ class.(a) Base, base(b) Derived, derived(c) Derived, base(d) Base, derivedThis question was posed to me in an interview.Query is from Virtual Functions topic in chapter Member Functions & its Types of Object Oriented Programming |
|
Answer» Correct choice is (d) Base, derived |
|
| 123. |
Which among the following is true for virtual functions?(a) Prototype must be different in base and derived class(b) Prototype must be same in base class and derived class(c) Prototype must be given only in base class(d) Prototype must have different signature in base and derived classI had been asked this question by my college professor while I was bunking the class.I need to ask this question from Virtual Functions in section Member Functions & its Types of Object Oriented Programming |
|
Answer» Right option is (B) Prototype must be same in BASE class and derived class |
|
| 124. |
Which is a must condition for virtual function to achieve runtime polymorphism?(a) Virtual function must be accessed with direct name(b) Virtual functions must be accessed using base class object(c) Virtual function must be accessed using pointer or reference(d) Virtual function must be accessed using derived class object onlyThis question was addressed to me in an international level competition.This intriguing question comes from Virtual Functions topic in section Member Functions & its Types of Object Oriented Programming |
|
Answer» RIGHT answer is (c) VIRTUAL function MUST be accessed using pointer or reference Easy explanation - The virtual functions must be called using pointer or reference. This is MANDATORY so that the intended function GETS executed while resolving the method at runtime. The must not be any ambiguity between the method of parent class and derived class. |
|
| 125. |
Virtual functions can’t be made friend function of other classes.(a) True(b) FalseThe question was asked in exam.This question is from Virtual Functions in division Member Functions & its Types of Object Oriented Programming |
|
Answer» CORRECT answer is (a) True Explanation: The friend functions can ACCESS the PRIVATE members also. This may hinder the SECURITY of class members. This is why the functions should not be made friend functions of other class. |
|
| 126. |
Virtual functions can never be made _______________(a) Static function(b) Parameterized function(c) Default argument function(d) Zero parameter functionI have been asked this question in final exam.I want to ask this question from Virtual Functions in portion Member Functions & its Types of Object Oriented Programming |
|
Answer» CORRECT OPTION is (a) Static function To EXPLAIN: The virtual function must not be static. Those functions are the property of individual objects and not of a CLASS as a WHOLE. The functions should not be made common for all the objects of that class. |
|
| 127. |
In which access specifier should a virtual function be defined?(a) Private(b) Public(c) Protected(d) DefaultThis question was addressed to me by my school principal while I was bunking the class.The question is from Virtual Functions topic in chapter Member Functions & its Types of Object Oriented Programming |
|
Answer» Right CHOICE is (b) Public |
|
| 128. |
The resolving of virtual functions is done at ______________(a) Compile time(b) Interpret time(c) Runtime(d) Writing source codeThe question was posed to me in an interview for job.Origin of the question is Virtual Functions topic in chapter Member Functions & its Types of Object Oriented Programming |
|
Answer» Correct option is (C) Runtime |
|
| 129. |
Where the virtual function should be defined?(a) Twice in base class(b) Derived class(c) Base class and derived class(d) Base classI had been asked this question during an online exam.This interesting question is from Virtual Functions topic in division Member Functions & its Types of Object Oriented Programming |
|
Answer» The correct CHOICE is (d) BASE CLASS |
|
| 130. |
Which keyword is used to declare virtual functions?(a) virtual(b) virt(c) anonymous(d) virtuallyI got this question during an interview.Origin of the question is Virtual Functions in division Member Functions & its Types of Object Oriented Programming |
|
Answer» The correct CHOICE is (a) virtual |
|
| 131. |
Virtual functions are mainly used to achieve _____________(a) Compile time polymorphism(b) Interpreter polymorphism(c) Runtime polymorphism(d) Functions code polymorphismI had been asked this question during an interview for a job.Question is from Virtual Functions topic in portion Member Functions & its Types of Object Oriented Programming |
|
Answer» Right answer is (C) Runtime POLYMORPHISM |
|
| 132. |
Virtual function is ______ class function which expected to be redefined in ______ class, so that when reference is made to derived class object using pointer then we can call virtual function to execute ________ class definition version.(a) Base, derived, derived(b) Derived, Derived, Derived(c) Base, derived, base(d) Base, base, derivedThis question was addressed to me in unit test.I need to ask this question from Virtual Functions topic in chapter Member Functions & its Types of Object Oriented Programming |
|
Answer» Right answer is (a) Base, derived, derived |
|
| 133. |
What does a virtual function ensure for an object, among the following?(a) Correct method is called, regardless of the class defining it(b) Correct method is called, regardless of the object being called(c) Correct method is called, regardless of the type of reference used for function call(d) Correct method is called, regardless of the type of function being called by objectsThe question was posed to me in an online interview.This intriguing question originated from Virtual Functions in portion Member Functions & its Types of Object Oriented Programming |
|
Answer» The correct choice is (c) Correct method is called, regardless of the type of reference used for FUNCTION call |
|