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

Can substring create new object?

560


Using callable statement how can you pass out parameters, explain with example?

590


What is a numeric digit?

586


How can we make sure main() is the last thread to finish in java program?

671


What are the basics of core java?

548






What is a boolean structure?

559


What are the differences between wait() and sleep()?

541


Is void a data type in java?

526


What is unsigned char?

618


What is an iterator interface in java programming?

536


What is called module?

567


What is the purpose of stub and skeleton?

549


What is meant by distributed application? Why are we using that in our application?

549


What is the difference between equals() and?

589


what are different ways in which a thread can enter the waiting state? : Java thread

494