wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes totally how many objects will be created? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "totally how many objects will be created? " Watch "totally how many objects will be created? " New topic
Author

totally how many objects will be created?

varinder mahajan
Ranch Hand

Joined: Jun 11, 2008
Posts: 47
In the declaration of strings,
String s1="abc";
String s2="xyz";
String s3=new String("abcd");
totally how many objects will be created?


Beat the world,if you can.......
Deepak Bajoria
Ranch Hand

Joined: Mar 07, 2008
Posts: 35
Heres 3 strings created here


SCJP 5 - 93%
mahesh chandra
Greenhorn

Joined: Dec 18, 2007
Posts: 12
totally 4 objects will be created

when you say String s1="abc"; it will create one string object in the string pool and s1 reference varible will be refering that,where as String s3=new String("abcd"); creates one string poll object and one string object and reference varible s3 will be refering the object created in the pool
so totally 4
Ronald Schild
Ranch Hand

Joined: Jun 09, 2008
Posts: 117
There will be 4 String objects after this code has run.


Java hobbyist.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: totally how many objects will be created?
 
Similar Threads
String objects
How many objects are created?
How many String objects created
String pool
String and String Object Problem