🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← All topics

Quiz: C++ Classes and Objects: questions with answers

10 questions, each with the answer and a short explanation.

Take the timed quiz + get a certificate →
  1. Q1. What is the default access level of members in a C++ class?
  2. Q2. When does a destructor run?
  3. Q3. What does this print? (code)
  4. Q4. What does a const member function promise?
  5. Q5. How many copies of a static data member exist for 100 objects?
  6. Q6. What does this print? (code)
  7. Q7. What does this print? (code)
  8. Q8. Why should members be set in the constructor's initializer list rather than by assignment in the body?
  9. Q9. Why can a static member function not use non-static data members directly?
  10. Q10. A setter returns this by reference. What does this make possible?