C++ OOPs Concepts | Set 3
21. How compile-time polymorphisms are implemented in C++?
a) Using Inheritance
b) Using Virtual functions
c) Using Templates
d) Using Inheritance and Virtual functions
Answer: C
Explanation: Compile-time polymorphism is implemented using templates in which the types(which can be checked during compile-time) are used decides which function to be called.
22. Which of the following is an abstract data type?
a) int
b) float
c) class
d) string
Answer: C
Explanation: Class is used as an abstract data type as it can be used to give implementation independent view whereas no other data type can be used to provide this.
23. Which concept means the addition of new components to a program as it runs?
a) Data hiding
b) Dynamic binding
c) Dynamic loading
d) Dynamic typing
Answer: C
Explanation: Dynamic loading is the concept of adding new components to a program as it runs.
24. Which of the following explains the overloading of functions?
a) Virtual polymorphism
b) Transient polymorphism
c) Ad-hoc polymorphism
d) Pseudo polymorphism
Answer: C
Explanation: Ad-hoc polymorphism is a type of polymorphism in which a function denotes heterogeneous implementation depending upon the types of argument.
25. Which of the following approach is used by C++?
a) Top-down
b) Bottom-up
c) Left-right
d) Right-left
Answer: B
Explanation: C++ is an object-oriented language and OOL uses a bottom-up approach to solve/view a problem.
26. Which operator is overloaded for a cout object?
a) >>
b) <<
c) <
d) >
Answer: B
Explanation: cout in C++ uses << operator to print anything so << operator is overloaded for a cout object.
27. Which of the following cannot be used with the virtual keyword?
a) Class
b) Member functions
c) Constructors
d) Destructors
Answer: C
Explanation: Virtual keyword cannot be used with constructors as constructors are defined to initialized an object of particular class hence no other class needs constructor of other class.
28. Which concept is used to implement late binding?
a) Virtual functions
b) Operator functions
c) Constant functions
d) Static functions
Answer: A
Explanation: Virtual functions are used to implement the concept of late binding i.e. binding actual functions to their calls.
29. Which of the following is correct?
a) C++ allows static type checking
b) C++ allows dynamic type checking.
c) C++ allows static member function to be of type const.
d) C++ allows both static and dynamic type checking
Answer: D
Explanation: C++ allows both static and dynamic type checking i.e. types are checked by the compiler.
30. Which of the following supports the concept that reusability is a desirable feature of a language?
a) It reduces the testing time
b) It reduces maintenance cost
c) It decreases the compilation time
d) It reduced both testing and maintenance time
Answer: D
Explanation: As we will be using the existing code therefore we don’t need to check the code again and again so testing and maintenance time decreases but the compiler time may increase or remains same because though we are reusing the code but every part needs to be compiled and extra include statement needs to be executed therefore compilation time may remain same or increases.