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 method overriding?
What is the benefit of inner classes in java?
How will you invoke any external process in java?
Can you inherit a constructor java?
What is the java idl system?
Can an interface extend another interface?
Can a class declared as private be accessed outside it’s package?
Is java developer a good career?
Differentiate between nested and inner class in java.
What is the purpose of java?
Is arraylist zero based?
What is the static field modifier?
How do you use compareto?
What is the use of arraylist in java?
What is the difference between preemptive scheduling and time slicing in java programming?