A directory of Objective Type Questions covering all the Computer Science subjects. Here you can access and discuss Multiple choice questions and answers for various compitative exams and interviews.

1. 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, derived
View Answer Report Discuss Too Difficult!
Answer: (a).Base, derived, derived

2. 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 objects
View Answer Report Discuss Too Difficult!
Answer: (c).Correct method is called, regardless of the type of reference used for function call

3. Virtual functions are mainly used to achieve _____________
a. Compile time polymorphism
b. Interpreter polymorphism
c. Runtime polymorphism
d. Functions code polymorphism
View Answer Report Discuss Too Difficult!
Answer: (c).Runtime polymorphism

4. Which keyword is used to declare virtual functions?
a. virtual
b. virt
c. anonymous
d. virtually
View Answer Report Discuss Too Difficult!
Answer: (a).virtual

5. Where the virtual function should be defined?
a. Twice in base class
b. Derived class
c. Base class and derived class
d. Base class
View Answer Report Discuss Too Difficult!
Answer: (d).Base class

6. The resolving of virtual functions is done at ______________
a. Compile time
b. Interpret time
c. Runtime
d. Writing source code
View Answer Report Discuss Too Difficult!
Answer: (c).Runtime

7. In which access specifier should a virtual function be defined?
a. Private
b. Public
c. Protected
d. Default
View Answer Report Discuss Too Difficult!
Answer: (b).Public

8. Virtual functions can never be made _______________
a. Static function
b. Parameterized function
c. Default argument function
d. Zero parameter function
View Answer Report Discuss Too Difficult!
Answer: (a).Static function

9. Virtual functions can’t be made friend function of other classes.
a. True
b. False
c. May be
d. Can't say
View Answer Report Discuss Too Difficult!
Answer: (a).True

10. Which is 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 only
View Answer Report Discuss Too Difficult!
Answer: (c).Virtual function must be accessed using pointer or reference

Page 1 of 12