Question: Please explain why s1 == s2 is false and why s2 == s4 is true. (drawing the picture of heap and stack gonna be more

Please explain why s1 == s2 is false and why s2 == s4 is true. (drawing the picture of heap and stack gonna be more helpful ! )

Assume the following code segment:

String s1 = "hello"; String s2 = s1; String s3 = new String( "hello" ); String s4 = "hello"; String s5 == new String( "hello" ); s1 = "hello world";

Which of the following statements is true?

a) s1 == s2 is true b) s3 == s4 is true c) s3 == s5 is true d) s2 == s4 is true

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!