MCQ Hive stays free thanks to ads. Please disable your ad blocker for this site so content and features keep working.
Fundamental Programming
Object-Oriented Concepts
Beginner
Q
What makes a C++ class abstract?
AIt is declared with the abstract keyword
BIt has no constructor
CIt has at least one pure virtual function (= 0)
DAll of its members are private
Correct Answer:
C. It has at least one pure virtual function (= 0)
Explanation:
C++ has no abstract keyword (Java and C# do). An abstract class cannot be instantiated.
ALSO KNOW (related points):
• Which C++ members can be declared virtual? → Destructors can be virtual; constructors cannot
• What is the default member access in a C++ class and in a C++ struct? → class: private; struct: public
• Which statement correctly distinguishes overloading from overriding? → Overloading is resolved at compile time; overriding a virtual function is resolved at run time
• In Python, a class defines self.__secret = 1. Which statement is true? → The name is mangled to _ClassName__secret but is still accessible from outside
• Which statement about a C++ friend function is correct? → It is not a member of the class but can access the class's private members
• A Car class holds an Engine object as a data member. Which relationship is this? → Composition (has-a)