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

Hi friends am new to java. I read jar file means collection of java files. For executing struts application what are the necessary jar files. " struts.jar " file contains what. can u explain

1435


What is public static void main?

567


What are the uses of java?

570


What is the importance of hashcode() and equals() methods?

581


How many techniques can be employed to create a string object?

559






What is assembly used for?

504


What is compareto?

544


How to display all the prime numbers between 1 and 100

505


How do you write methodology?

563


What is ‘has a’’ relationship in java?

724


What does method mean?

515


How do you compare objects in java?

503


Is string an object?

655


Can a class be declared as protected?

537


When object is created and destroyed?

640