aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes String Objects count Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "String Objects count" Watch "String Objects count" New topic
Author

String Objects count

Nimit Shah
Ranch Hand

Joined: Jul 02, 2007
Posts: 53
See the following code.


11. public String makinStrings() {
12. String s = "Fred";
13. s = s + "47";
14. s = s.substring(2, 5);
15. s = s.toUpperCase();
16. return s.toString();
17. }
How many String objects will be created when this method is invoked?
A. 1
B. 2
C. 3
D. 4
E. 5
F. 6
Answer: C

I thought that the answer would be E i.e. 5 String objects created.

Can anybody please explain me how comw the answer is C?
Manfred Klug
Ranch Hand

Joined: Jun 04, 2007
Posts: 377
Hi Nimit,

hava a look here.
[ July 09, 2007: Message edited by: Manfred Klug ]
 
 
subject: String Objects count