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...

String is an immutable object.
Then how can the following code be justified.

String s1 = ?ABC?;
String s1 = s1+?XYZ?;
s.o.p(s1);

The output is ABCXYZ, which is the value of s1 ?

Answer Posted / vishal

in the later case a different overloaded contructor is
invoked while in the prior case a different.As in the later
case a different constructor initializes the string s1 with
different values hence the result

Is This Answer Correct ?    4 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Define how can we find the actual size of an object on the heap?

1210


What is annotation in java?

1052


Which is better stringbuffer or stringbuilder?

920


What are the disadvantages of object oriented programming?

1280


Can a private method be declared as static?

1022


What is the history of java?

1003


What type of variable is gender?

990


Can we increase array size dynamically in java?

954


What is method overloading with type promotion?

1275


What is the console in java?

1162


How do you check if a character in a string is a digit or letter?

1076


Can you tell me range of byte?

992


Is string a class?

1039


What is the byte order of byte buffer?

1024


What is remote method invocation (rmi)?

1067