InterviewSolution
Saved Bookmarks
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.
| 151. |
Which alternative can replace the throw statement?(a) for(b) break(c) return(d) exit |
|
Answer» Right option is (c) return Easiest explanation - throw and return does the same job as return a value. So it can be replaced. |
|
| 152. |
Why we use :: template-template parameter?(a) binding(b) rebinding(c) both binding & rebinding(d) reusing |
|
Answer» Correct option is (c) both binding & rebinding To explain I would say: It is used to adapt a policy into binary ones. |
|
| 153. |
Which container is used to store elements as key-value pair?(a) map(b) multimap(c) unordered map(d) all of the mentioned |
|
Answer» Correct choice is (d) all of the mentioned Easy explanation - C++ provides these three containers(map, multimap and unordered map) to store elements as key-value pair. |
|
| 154. |
What is Inheritance in C++?(a) Wrapping of data into a single class(b) Deriving new classes from existing classes(c) Overloading of classes(d) Classes with same names |
|
Answer» Correct answer is (b) Deriving new classes from existing classes The best explanation: Inheritance is the concept of OOPs in which new classes are derived from existing classes in order to reuse the properties of classes defined earlier. |
|
| 155. |
How many specifiers are used to derive a class?(a) 1(b) 2(c) 3(d) 4 |
|
Answer» Right choice is (c) 3 To explain: There are 3 specifiers used to derive a class. They are private, protected and public. |
|
| 156. |
What is the use of RAII in c++ programming?(a) Improve the exception safety(b) Terminate the program(c) Exit from the block(d) Crash the compiler |
|
Answer» Right option is (a) Improve the exception safety Easy explanation - RAII is used to improve the exception safety. |
|
| 157. |
Which statement is incorrect about virtual function.(a) They are used to achieve runtime polymorphism(b) They are used to hide objects(c) Each virtual function declaration starts with the virtual keyword(d) All of the mentioned |
|
Answer» Right choice is (b) They are used to hide objects Best explanation: Virtual function are used to achieve runtime polymorphism by calling the right function during runtime. Their declaration starts with a virtual keyword. |
|
| 158. |
Which is the correct syntax of declaring a virtual function?(a) virtual int func();(b) virtual int func(){};(c) inline virtual func();(d) inline virtual func(){}; |
|
Answer» The correct answer is (a) virtual int func(); To explain I would say: To make a function virtual function we just need to add virtual keyword at the starting of the function declaration. |
|
| 159. |
The concept of deciding which function to invoke during runtime is called ______________________(a) late binding(b) dynamic linkage(c) static binding(d) both late binding and dynamic linkage |
|
Answer» Right option is (d) both late binding and dynamic linkage To explain I would say: The concept of deciding which function to invoke during runtime is called late binding or dynamic linkage. Late binding because function binding to the object is done during runtime. Dynamic linkage because this binding is done during runtime. |
|
| 160. |
Pick out the correct answer.(a) Exceptions are not suitable for critical points in code(b) Exception are suitable for critical points in code(c) Exceptions are used when postconditions of a function cannot be satisfied(d) Throw block should be placed after try block |
|
Answer» Correct answer is (a) Exceptions are not suitable for critical points in code The explanation is: If there is many number of exceptions in the program means, We have to use multiple catch statement and it is hard to keep track of the program. |
|
| 161. |
How many runtime error messages associated with exception?(a) 2(b) 4(c) 5(d) infinite |
|
Answer» Right answer is (b) 4 For explanation: There are four runtime error messages associated with exceptions. They are overflow_error, range_error, system_error and underflow_error. |
|
| 162. |
Where exception are handled?(a) inside the program(b) outside the regular code(c) both inside or outside(d) main program |
|
Answer» Correct answer is (b) outside the regular code The explanation: Exception are handled outside the regular code. |
|
| 163. |
Which class is used to design the base class?(a) abstract class(b) derived class(c) base class(d) derived & base class |
|
Answer» Right option is (a) abstract class For explanation: Abstract class is used to design base class because functions of abstract class can be overridden in derived class hence derived class from same base class can have common method with different implementation, hence forcing encapsulation. |
|
| 164. |
Which is also called as abstract class?(a) virtual function(b) pure virtual function(c) derived class(d) base class |
|
Answer» Correct option is (b) pure virtual function The explanation: Classes that contain at least one pure virtual function are called as abstract base classes. |
|