Tutorials - C++ Programming Quiz on C++ Classes

Quiz: C++ Classes

If you don't feel like you answered these questions to your satisfaction, be sure to read through Cprogramming.com's Classes in C++ tutorial. Otherwise, nice job!

1. What purpose do classes serve?
A. data encapsulation
B. providing a convenient way of modeling real-world objects
C. simplifying code reuse
D. all of the above

2. Which is not a protection level provided by classes in C++?
A. protected
B. hidden
C. private
D. public

3. What value must a destructor return?
A. A pointer to the class.
B. An object of the class.
C. A status code determining whether the class was destructed correctly
D. Destructors do not return a value.

4. Which of the following is a valid class declaration?
A. class A { int x; };
B. class B { }
C. public class A { }
D. object A { int x; };

5. Which functions will every class contain?
A. None
B. Constructor
C. Destructor
D. Both a constructor and a destructor

Answer Key
Next lesson: Lesson 13, inline functions