Question 85Asked in BPSC TRE 2.0 (2023) Computer Class 9-10

How do structures and classes in C++ differ?

  1. AIn structures, members are private by default whereas in classes, they are public by default
  2. BIn structures, members are public by default whereas in classes, they are private by default
  3. CStructures cannot have private members whereas classes can have
  4. DMore than one of the above
  5. ENone of the above
Show answerHide answer

Correct answer: (B) In structures, members are public by default whereas in classes, they are private by default

Explanation

In C++ the members of a struct are public by default, while those of a class are private by default.

From BPSC TRE 2.0 (2023) Computer Class 9-10 — Previous Year Paper

This is question 85 of BPSC TRE 2.0 (2023) Computer Class 9-10 — Previous Year Paper. See all questions of this paper with answers, or attempt the paper as a timed online test to get your score and all-India rank.