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 / paras bist
above program is incorrect ,it will give compile time error
as "Duplicate Variable s1".
it should b
String s1 = "ABC";
String s = s1+"XYZ";
which is valid in string ,as we are creating new String
object
| Is This Answer Correct ? | 14 Yes | 2 No |
Post New Answer View All Answers
What do you understand by garbage collection in Java? Can it be forced to run?
When is the garbage collection used in Java?
What is the difference between array list and vector in java?
What is a singleton in genetics?
Is string a data type in java?
Can static methods be inherited?
State the significance of public, private, protected class?
can used Protected Class outside Function.?
What is array in java?
What are the differences between getting and load method?
Can a static method be final?
What are generic methods?
Is 0 true or false?
What is the use of set in java?
Can an interface extend another interface?