Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

C++ | Class and Object | Question 4

  • Last Updated : 28 Jun, 2021

Which of the following is true?
(A) All objects of a class share all data members of class
(B) Objects of a class do not share non-static members. Every object has its own copy.
(C) Objects of a class do not share codes of non-static methods, they have their own copy
(D) None of the above

Answer: (B)

Explanation: Every object maintains a copy of non-static data members. For example, let Student be a class with data members as name, year, batch. Every object of student will have its own name, year and batch. On a side note, static data members are shared among objects.
All objects share codes of all methods. For example, every student object uses same logic to find out grades or any other method.

Quiz of this Question

Take a step-up from those "Hello World" programs. Learn to implement data structures like Heap, Stacks, Linked List and many more! Check out our Data Structures in C course to start learning today.
My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!