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 synchronized methods and synchronized statements in java programming?
What is a private class in java?
What is collections framework?
What is a pattern what is an anti pattern?
what are synchronized methods and synchronized statements? : Java thread
What is static import in java?
What is the private method modifier?
What are reference variables in java?
Difference between object instantiation and construction ?
What are the different http methods?
What are the two types of java programming?
How do you reverse a list?
Define nashorn in java8.
What are the 8 primitive data types in java?
How do you replace a string in java?