Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
5 objects.
--------------------
Regards,
Mani Vannan
SCJP- 98%<br />SCWCD-92%
Line 1 creates two: String constant "xyz" in the StringPool and the newly created String in the heap. I agree with the other lines, so I think the answer should be 4.Originally posted by Mahendar Chada:
hello friends,
I hope ans is 3 but not 5.
String x = new String("xyz");
String y="abc";
x=x+y;
--------------------------------------------------------------------------------
Line 1 - 1 object...in heap
Line 2 - 1 object in StringPool(special type of memory)
Line 3 - 1 object in heap.
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
SCJP- 98%<br />SCWCD-92%
Regards<br />Mandy<br /> <br />-----------------<br />Thinking,Thinking,Thinking,<br />Before you do any action!!!
Cheers,<br />Jay<br /> <br />(SCJP 1.4)<br />Heights of great men were not achieved in one day, they were toiling day and night while their companions slept.
Better, faster, lighter Java ... you mean Ruby right ?
SCEA5,SCBCD1.3,SCWCD5,SCJP1.4 - memories from my youth.
SCJP- 98%<br />SCWCD-92%
Better, faster, lighter Java ... you mean Ruby right ?
SCEA5,SCBCD1.3,SCWCD5,SCJP1.4 - memories from my youth.
String x = new String("xyz");
// one reference variable, one string object"xyz"
SCJP- 98%<br />SCWCD-92%
Harish<br />SCJP 1.4 (85%)
I don't know from where u got this concept.
Originally posted by harish shankarnarayan:
total four objects according to me
Corey McGlone,Marcus Green, Barry Gaunt, Jason Menard, Dirk
Cheers,<br />Jay<br /> <br />(SCJP 1.4)<br />Heights of great men were not achieved in one day, they were toiling day and night while their companions slept.
Originally posted by Steve Morrow:
Apparently, I haven't reached "trustworthy" status yet...
Keep Smiling Always — My life is smoother when running silent. -paul
[FAQs] [Certification Guides] [The Linux Documentation Project]
Don't get me started about those stupid light bulbs. |