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 multithreading and its advantages?
What is finally block?
Explain creating threads by extending thread class ?
What is super keyword explain with example?
What is ternary operator in java?
Can you inherit from an abstract class java?
Explain different ways of creating a thread. Which one would you prefer and why?
What are the types of methodology?
How many ways can we create the string object?
Explain the difference between abstraction and encapsulation.
What is the difference between the jdk 1.02 event model and the event-delegation model introduced with jdk 1.1?
What is :: operator in java?
who can i handle multiple client in RMI
How to obtain a performance profile of java program
Explain thread life cycle in java?