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

What is used of static keyword in java?

1065


How does predicate work in java?

974


What is a protected void?

921


Can we convert stringbuilder to string in java?

980


What is :: operator in java 8?

1013


What is nullpointerexception in java?

1140


What is difference between java and java ee?

1024


What environment variables are required to be set on a machine in order to run Java programs?

1187


Can we extend singleton class in java?

958


What does three dots mean in java?

1119


Can we execute a program without main?

1014


What is an example of a constant variable?

1077


What is implicit object in java?

1075


What is java argument list?

932


What string is utf8?

991