1.

Which among the following is wrong syntax related to static data members?(a) className :: staticDataMember;(b) dataType className :: memberName =value;(c) static dataType memberName;(d) className : dataType -> memberName;The question was posed to me in an interview.My doubt stems from Static Data Members topic in chapter Exception Handling & Static Class Members of Object Oriented Programming

Answer»

Correct ANSWER is (d) CLASSNAME : dataType -> memberName;

Explanation: The syntax given in option d doesn’t belong to any PARTICULAR declaration or definition. First one is to access the static members USING the CLASS name. Second is to define the static data outside the class. Third syntax id to declare a data member as static in a class.



Discussion

No Comment Found

Related InterviewSolutions