Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

How many objects are created when we create String class
object using new operator?

Answer Posted / ravi

Eknath Wagadre is correct, Check this programme.

String s1 = "this is string";
String s2 = new String("this is string");

System.out.format("S1: %d, S2:%d \n",s1.hashCode(),s2.hashCode() );
System.out.println(s1.hashCode()==s2.hashCode() );

The both s1 and s2 have same hashCode, means only one object created.

Is This Answer Correct ?    0 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can It is possible to synchronize the constructor of a Java Class?

1061


What is JDBC Driver interface?How can you retrieve data from the ResultSet

2061


How to create a thread in java?

1099


How does singleton class work?

956


What is the purpose of file class?

983


What does || mean in vectors?

899


What is java volatile?

984


What is thread synchronization in java?

869


What is entry set in java?

1065


How do you convert bytes to character in java?

959


In the below example, how many string objects are created?

1001


What is a newline character in java?

1009


Can you change array size in java?

928


Can final class have constructor?

886


Can you inherit a constructor java?

1039