1).what is the difference between below examples

String s="vijay";

String s=new String("vijay");

Answer Posted / karun

In first statement String s = "vijay"

Means it will create a single instance and single reference
variable

but in second statement

String s = new String("vijay");

Means it will create a two instances and single reference
variable

Is This Answer Correct ?    4 Yes 7 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the memory leak in java?

530


What is the symbol for space?

565


How many types of constructors are used in java?

543


What is sortedset in java?

578


When do you call copy constructor?

561






how to run ecllipse with jettyserver for windows environment using batch file

1501


What is number data type in java?

560


Can we sort hashset in java?

633


What is the impact of declaring a method as final?

565


Explain the difference between jvm and jre?

564


What is string pool?

629


Why is flag used in java?

553


What do you understand by overloading and overriding in java?

549


Can a class extend more than one class?

618


What will happen if there is a default method conflict as mentioned above and we have specified the same signature method in the base class instead of overriding in the existing class ?

522