MCQ - OOPS Concept in C++ Programming
21. Which of the following access specifier is used as a default in a class definition?
A. Private
B. Public
C. Friend
D. Protected
View Answer
Ans : A
Explanation: Private access specifier is used as a default in a class definition.
22. Not using virtual destructor feature in a C++ object oriented programing can cause
A. An Issue in creating object of the class
B. Memory leak
C. An issue in calling base class destructor
D. None of the above
View Answer
Ans : B
Explanation: Virtual destructor is used to maintain the hierarchy of destructor calls for polymorphic classes in inheritance. If we don't use it then it may cause resource leak or memory leak.
23. If private member functions are to be declared in C++ then __________
A. private(private member list)
B. private
C. private:
D. private :-
View Answer
Ans : C
Explanation: The private members doesn't have to have the keyword with each private member. We only have to specify the keyword private followed by single colon and then private member's are listed.
24. The order in which operands are evaluated in an expression is predictable if the operator is
A. Addition
B. Modulus
C. Multiply
D. &&
View Answer
Ans : D
Explanation: The order in which operands are evaluated in an expression is not defined by the language and is compiler-dependent. For example, pop ( ) - pop ( ) may do (current top stack) - (the data just below the current top), or vice-versa, depending on which pope ) call is executed first.
However, the order of evaluation for the operator & & is defined by the language. It evaluates from left to right. Do not confuse order of evaluation with associativity.
25. Which of the following is a mechanism of static polymorphism?
A. Templates
B. Function overloading
C. Operator overloading
D. All of the above
View Answer
Ans : D
Explanation: Function overloading is a mechanism of static polymorphism.
26. IS A relationship in C++ is
A. Inheritance
B. Encapsulation
C. Composition
D. None of the above
View Answer
Ans : A
Explanation: IS A relationship in C++ is Inheritance.
27. Which of the following correctly describes overloading of functions?
A. Virtual polymorphism
B. Transient polymorphism
C. Ad-hoc polymorphism
D. Pseudo polymorphism
View Answer
Ans : C
Explanation: None
28. How many loops are there in C++ 98?
A. 2
B. 3
C. 4
D. 5
View Answer
Ans : B
Explanation: for, while & do-while loops are available
Also check :
Discussion