1. How compile-time polymorphisms are implemented in C++?
a) Using Inheritance
b) Using Virtual functions
c) Using Templates
d) Using Inheritance and Virtual functions
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.
2. Which of the following is an abstract data type?
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.
3. 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
Explanation: Dynamic loading is the concept of adding new components to a program as it runs.
4. Which of the following explains the overloading of functions?
a) Virtual polymorphism
b) Transient polymorphism
c) Ad-hoc polymorphism
d) Pseudo polymorphism
Explanation: Ad-hoc polymorphism is a type of polymorphism in which a function denotes heterogeneous implementation depending upon the types of argument.
5. Which of the following approach is used by C++?
Explanation: C++ is an object-oriented language and OOL uses a bottom-up approach to solve/view a problem.
6. Which of the following is not a fundamental type is not present in C but present in C++?
Explanation: Boolean type is not present as a fundamental type in C. int type is used as boolean in C whereas in C++ bool is defined as a fundamental type for handling boolean outputs.
7. What is the size of a boolean variable in C++?
a) 1 bit
b) 1 byte
c) 4 bytes
d) 2 bytes
Explanation: Boolean uses only 1 bit as it stores only truth values which can be true(1) or false(0).
8. Which of the following is C++ equivalent for scanf()?
Explanation: C++ uses cin to read input form uses. However C++ also uses scanf().
9. Which of the following is C++ equivalent for printf()?
Explanation: C++ uses cout to print output to console. However C++ also uses printf().
10. Which of the following is the correct difference between cin and scanf()?
a) both are the same
b) cin is a stream object whereas scanf() is a function
c) scanf() is a stream object whereas cin is a function
d) cin is used for printing whereas scanf() is used for reading input
Explanation: cin is a stream object available in C++ whereas scanf() is a function available in both C and C++. both are used for reading input from users.