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


Please Help Members By Posting Answers For Below Questions

What sorting algorithm does javascript use?

524


What is the independent variable in an experiment?

544


Explain about java sdk?

574


What is null data type?

532


What does it mean that a method or field is “static”?

544






What is the difference between static class and normal class?

482


Can a class have 2 constructors?

491


What is anti pattern in cyber security?

516


What is a literal coding?

508


How to sort elements in a parallel array in java?

499


In how many ways we can do exception handling in java?

569


What is use of super keyword in java?

592


What is valid keyword in java?

545


What do you mean by an interface in java?

562


What is a wrapper method?

528