1.

Whenever any static data member is declared in a class ______________________(a) Only one copy of the data is created(b) New copy for each object is created(c) New memory location is allocated with each object(d) Only one object uses the static dataThis question was posed to me in examination.My question is based upon Static Data Members topic in division Exception Handling & Static Class Members of Object Oriented Programming

Answer» RIGHT answer is (a) Only one copy of the data is created

The best I can explain: The static data is same for all the objects. Instead of creating the same data each TIME an object is created, the compiler created only one data which is accessed by all the objects of the CLASS. This saves memory and reduces redundancy.


Discussion

No Comment Found

Related InterviewSolutions