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
Which package has light weight components in java programming?
Can a class be protected in java?
what is the constructor and how many types of constructors are used in java?
What is meant by JVM? Is JVM platform independent or not?
What is the dot operator?
Considering notepad/ie or any other thing as process, what will happen if you start notepad or ie 3 times? Where 3 processes are started or 3 threads are started?
Explain when classnotfoundexception will be raised ?
What is the difference between path and classpath variables?
What is a jagged array in java?
Which api is provided by java for operations on set of objects?
What is method in research paper?
What is a wrapper method?
Tell me about different OOPS concepts.
Does sprintf add a null terminator?
Define how objects are stored in java?