my dog learned polymorphism*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes How many string objects Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "How many string objects" Watch "How many string objects" New topic
Author

How many string objects

Sneha Kapoor
Ranch Hand

Joined: Jun 08, 2009
Posts: 49

Hi All,




As per understanding there are 3 objects 1)Fred 2)47 3)s.toString(); on line 16

am i right??
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3859

Please QuoteYourSources. Simple search for "fred 47" in the forum will give you the answer for this.


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Sneha Kapoor
Ranch Hand

Joined: Jun 08, 2009
Posts: 49
Source: VoodooExam
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3859

Except toString() method all other operations will create a new object ( except s=s+"47" will make 2). For scjp level this is correct (as there are little more to this with regards to the String constants as they may have created already before the method invoked, at the class loading).
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9319
    
  17

Look here

http://www.coderanch.com/t/434127/Programmer-Certification-SCJP/certification/many-String-Objects-are-created#1930019


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How many string objects