Mastering C++: A Comprehensive Quiz Based on 'Thinking in C++'

Disable ads (and more) with a membership for a one time $2.99 payment

Test your C++ skills with our quiz based on Bruce Eckel's 'Thinking in C++'. Dive into object-oriented programming, advanced topics, and fundamentals. Perfect for learners and experts alike. Assess your knowledge and become a C++ master!

Each practice test/flash card set has 50 randomly selected questions from a bank of over 500. You'll get a new set of questions each time!

Practice this question and more.


For a class X in C++, what is true about its constructor?

  1. It must return a value

  2. It is called automatically when an object is declared

  3. It can only be called manually

  4. It cannot have any parameters

The correct answer is: It is called automatically when an object is declared

The constructor for a class in C++ is called automatically when an object is declared. This is known as default initialization, and serves to initialize the instance of the class to a known state. Options A, C, and D are incorrect because a constructor does not require a return value, can be called both automatically and manually, and can have parameters if necessary.