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 / paras bist

above program is incorrect ,it will give compile time error
as "Duplicate Variable s1".
it should b
String s1 = "ABC";
String s = s1+"XYZ";
which is valid in string ,as we are creating new String
object

Is This Answer Correct ?    14 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain the significance of class loaders in bootstrap?

1015


What is a singleton class? Give a practical example of its usage.

1147


Differentiate between run time error and syntax error.

1198


What are the advantages and disadvantages of reference counting in garbage collection?

1071


Program to Find the second largest element in an array.

1262


What does yield method of the thread class do?

1084


What do you mean by an object in java?

1186


Can we have 2 main methods in java class?

1069


What is the null?

1060


What is the inheritance?

1024


How do you sort data in java?

1005


what is aggregation in java?

1079


How do you identify if jvm is 32-bit or 64-bit from java program?

1011


Is java good for beginners?

1058


What is included in core java?

1100