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 / sivadasan
It will Give Compile time Error...
We can not declare again s1.
So the Compiler will give
s1 is already defined in main(java.lang.String[])
| Is This Answer Correct ? | 6 Yes | 0 No |
Post New Answer View All Answers
What are the parts of a method?
When should a function throw an exception?
What is the primitive type short?
What are the escape sequences in java?
Does anyone still use java?
What is integers and example?
What are the types of exceptions?
What is bufferedreader in java?
What is the static variable?
what is the purpose of using rmisecuritymanager in rmi?
What is a method in java?
Can a class have more than one object?
What is internal iteration in java se 8?
How do you use substring in java?
What is the difference between a window and a frame in java programming?