1.

The syntax for defining the static data members is __________(a) dataType className :: memberName = value;(b) dataType className : memberName = value;(c) dataType className . memberName = value;(d) dataType className -> memberName =value;I had been asked this question in an interview for job.My question is taken from Static Data Members in portion Exception Handling & Static Class Members of Object Oriented Programming

Answer»

Correct ANSWER is (a) dataType className :: memberName = value;

To explain I would say: The syntax doesn’t contain the static keyword. SINCE it is already been declared as static inside the class. The data type and the corresponding class name MUST be there to allocate the VARIABLE to a class. The value is assigned using scope resolution operator for the member name.



Discussion

No Comment Found

Related InterviewSolutions