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

What is an inner class in java?

518


Discuss different types of errors that generally occur while programming.

571


Explain the available thread states in a high-level?

522


What is ‘has a’’ relationship in java?

720


What Is Query Throttling in java?

555






How to disable caching on back button of the browser?

518


Is a case study a method or methodology?

459


What is method and methodology?

604


Which collection is thread safe in java?

505


What is the use of set in java?

606


Does google use java?

523


What is role of void keyword in declaring functions?

566


What is jrmp?

542


What does system out println () do?

551


How many static init can you have?

671