1.

How Many Object Will Be Created If Strings Are Created This Way? String S1 = “test”; String S2 = New String(“test”); String S3 = New String(“test”).intern();

Answer»

s1 will go to string pool, for s2 new object is CREATED. S3, though created using new will still search in the string pool for any REFERENCE having the same CONTENT as intern() method is used. So two objects will be created.

s1 will go to string pool, for s2 new object is created. S3, though created using new will still search in the string pool for any reference having the same content as intern() method is used. So two objects will be created.



Discussion

No Comment Found