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 do you understand by synchronization?
What is the difference between variable & constant?
Can a main method be declared final?
What is the flag in java?
Which is bigger float or double java?
Can a method inside a interface be declared as final?
Which category the java thread do fall in?
What is the difference between @before and @beforeclass annotation?
What are the two types of java?
Explain different types of wrapper classes in java?
What are three advantages of using functions?
What is the use of conditional statement?
What sorting algorithm does javascript use?
What do you mean by platform independence of Java?
Can a top level class be private or protected?