1).what is the difference between below examples

String s="vijay";

String s=new String("vijay");

Answers were Sorted based on User's Feedback



1).what is the difference between below examples String s="vijay"; String s=new Stri..

Answer / ravikiran

first one will create an object on the heap
second one will create two objects one will saved on the
heap and another will get saved on the string pool

Is This Answer Correct ?    0 Yes 6 No

1).what is the difference between below examples String s="vijay"; String s=new Stri..

Answer / p.sreekiran

in first string class it create in heep memory and second
is created object in constant memeory we cannot change the
second one

Is This Answer Correct ?    2 Yes 13 No

Post New Answer

More Core Java Interview Questions

what are class,constructor and primitive data types?

2 Answers   IBM,


How do I stop concurrentmodificationexception?

0 Answers  


What are java packages? What is the significance of packages?

0 Answers  


Can I import same package/class twice?

0 Answers  


What is the meaning of 3 dots in java?

0 Answers  






types of applets?.

7 Answers   TCS,


What is low level language in computer?

1 Answers  


Is namespace same as package in java?

0 Answers  


Can a class have more than one object?

0 Answers  


What is equlas() and hashcode() contract in java? Where does it used?

0 Answers  


What is the difference between exception and error in java?

0 Answers  


What are structs in java?

0 Answers  


Categories