Get new post automatically.

Enter your email address:


Quiz and Answers: C++ Classes

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