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 is the major advantage of external iteration over internal iteration?
What is final keyword in java?
What are the drawbacks of reflection?
How do you call a reference in java?
How does system arraycopy work in java?
What is java virtual machine and how it is considered in context of java’s platform independent feature?
How to store image in arraylist in java?
Compare overloading and overriding?
Which arithmetic operations can result in the throwing of an arithmeticexception?
Does constructor return any value?
What is a type parameter in java?
What is a boolean expression in java?
Can we define private and protected modifiers for variables in interfaces?
How does java enable high performance?
What is the difference between array and array list in java?