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 / ramesh

Compilation ERROR
Duplicate Variable s1.

Is This Answer Correct ?    2 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why we cannot override static method?

779


What is method overloading with type promotion?

940


what do you mean by marker interface in java?

777


How do I convert a string to an int in java?

804


Describe method overriding

831


How will you initialize an Applet?

853


Explain java coding standards for interfaces?

865


Why string is not thread safe?

776


How thread scheduler schedule the task?

830


What is final int?

741


Is 0 true or false in java?

770


which one is more efficient int x; 1. if(x==null) 2.if(null==x) state which one either 1 or 2?

10188


how to handle exceptions in ejb?

2112


Is java map thread safe?

717


Can a class with private constructor be extended?

716