CPP Class Practice Questions
The free CPP: C Certified Professional Programmer questions that deal with class, with answers and explanations. The full bank and the timed practice test cover every topic the exam asks about.
Question #2
You have an object of class Car. If Car contains a virtual destructor, what is its functionality?
Correct answer: B
Explanation
A virtual destructor ensures that the destructor of derived classes is called when deleting a base class pointer.
Question #3
In a class hierarchy, why is using a const reference preferable for function parameters?
Correct answer: B
Explanation
Const references avoid unnecessary copies, leading to improved performance, especially for large objects.
Question #4
If you overload the + operator for a class, what must it return?
Correct answer: B
Explanation
An overloaded + operator must return an instance of the class to reflect the result of the addition operation.
Question #5
What happens if you neglect to declare your class methods as virtual in the base class?
Correct answer: D
Explanation
If methods are not declared as virtual in a base class, derived classes cannot override them, leading to potential issues in polymorphism.
Continue with CPP: C Certified Professional Programmer
Unlock the full question bank
You have read the first 10 questions. A subscription opens every question in CPP: C Certified Professional Programmer, the full timed practice test, and your progress and weak-topic reporting.
Single exam
$19.99for 30 days
Full question bank and practice test for one exam, for 30 days.
Single exam
$49.99for 1 year
One exam for a full year. Nothing renews and nothing to cancel.
Full access
$39.99/mo
Every exam in the catalogue, month to month.
Full access
$199.99/yr
Every exam in the catalogue for a year.
Already subscribed? Sign in to pick up where you left off.
All CPP: C Certified Professional Programmer practice questions →
