1.

How to declare an object of class String?(a) String object_Name = value;(b) String object_name = new;(c) String object_name= new value;(d) String object_name= value new;

Answer» The correct answer is (a) String object_Name = value;

The best I can explain: The class name String is given. And then the object name is mentioned. There are two ways to declare and initialize the string. Either by giving direct string value or by using new keyword. But if new operator is used, constructor of String class have to be called. From the given options, the direct string value declaration is correct.


Discussion

No Comment Found

Related InterviewSolutions