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 / vishal
in the later case a different overloaded contructor is
invoked while in the prior case a different.As in the later
case a different constructor initializes the string s1 with
different values hence the result
| Is This Answer Correct ? | 4 Yes | 2 No |
Post New Answer View All Answers
what do you mean by classloader?
Is integer a class?
What is the implementation of destroy method in java. Is it native or java code?
What are different types of states exist for a thread?
What are the 3 types of control structures?
Why isn’t there operator overloading?
What is the major advantage of external iteration over internal iteration?
How do you sort arraylist in descending order?
Is .net better than java?
What is java util list?
Can you start a thread twice in Java?
Is class forname reflection?
What is application tier?
Is java 11 paid version?
Explain super keyword in java.