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

Is a method a procedure?

567


How do you trim a space in java?

509


What is a java list?

592


EDS (Electronic Data Systems India Pvt Ltd) at Chennai on 16-12-2006.

8635


What is string in java is it a data type?

546






What is data structure in java?

545


Differences between C and Java?

623


What’s the difference between unit, integration and functional testing?

624


What will be the default values of all the elements of an array defined as an instance variable?

566


How do you read and print a string in java?

532


how to create multithreaded program? : Java thread

519


What is the difference between compile-time polymorphism and runtime polymorphism?

576


What is an argument in java?

521


What is JDBC Driver interface?How can you retrieve data from the ResultSet

1519


Can a class with private constructor be extended?

498