Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

String Objects....

 
Alok Sinha
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got this question in one of the mock tests.It asks to count the no. of String objects created.
The given answer is 3 but I think it should be 2.
the question goes like thos:

String s1,s2,s3,s4;
s1="hello";
s2=s1;
s3=s2+"pal";
s1=s3;

[This message has been edited by Alok Sinha (edited November 26, 2000).]
 
zulfiqar raza
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Three string objects:
"hello"
"pal"
"hellopal"
"pal" would be an anonymous string object.
zulfiqar
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic