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 defined as false sharing in the context of multithreading?
How many bytes is a url?
What is string pooling concept?
Why string is a class?
State the main difference between c++ and java?
What is the difference between method and means?
What are the library functions in java?
Explain the use of volatile field modifier?
What is the benefit of abstract class?
What is a superclass?
What is file in java?
How many types of exception can occur in a java program?
Can a class with private constructor be extended?
Explain the features of interfaces in java?
What is meant by 'Class access modifiers'?