suppose string s1="rajnish";
string s2="bhaskar";
then what will be happend ?

Answer Posted / venkat

FIRST OF ALL THE JVM CREATED THE OBJECTS FOR STRING
CLASSESS IN TWO WAYS
1)STRING S1=NEW STRING("VENKI");
2)STRING S2="VENKI"
IN SECOND APPROACH WHEN THE JVM IS EN COUNTED THE ""
(DOUBLE QUOTATIONS) THEN IT UNDERSTOOD ,AND CREATED THE
OBJECT FOR THE S2 , AND THIS OBJECT IS PLACED IN THE STRING
POOL (SEPERATE MEMORY LOCATION IS MAINTAINED) . i.e in this
position we are not creating the object for the string class
explicitly ,the jvm internally created this object

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a native method in java programming?

515


What is the use of singleton?

504


How will you add panel to a frame?

633


What is the technique adopted to create an immutable class?

514


Can a method inside a interface be declared as final?

514






How to perform selection sort in java?

569


What are parameters in a method?

576


What is difference between word and integer?

584


Is node a data type in java?

487


Why null value is used in string?

519


What is the difference between the file and randomaccessfile classes?

520


Is null a string or object in java?

536


what is instanceof operator used in java?

581


What is ordered map in java?

529


Is singleton class immutable?

530