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
Which method cannot be overridden in java?
What is supplier in java?
What are the different types of collections in java?
What is the difference between the font and fontmetrics classes in java programming?
What is string substring?
what is the significance of listiterator in java?
Write a java program to print fibonacci series?
Is main is a keyword?
What is java and their uses?
What is the full name of java?
What is runtime polymorphism or dynamic method dispatch?
Can list be final in java?
Can a variable be local and static at the same time?
How can u increase the heap size in the memory?
What is a heavyweight component?