What is displayed when the following code is compiled and executed?
String s1 = new String("Test");
String s2 = new String("Test");
if (s1==s2)
System.out.println("Same");
if (s1.equals(s2))
System.out.println("Equals");
------------------------------------------------------------------------------------
A. Same
B. Equals
C. The code compiles, but nothing is displayed upon execution.
D. The code fails to compile.
<PREVIOUS || Main Page || NEXT >
GIVE YOUR ANSWER IN THE COMMENT BELOW
String s1 = new String("Test");
String s2 = new String("Test");
if (s1==s2)
System.out.println("Same");
if (s1.equals(s2))
System.out.println("Equals");
------------------------------------------------------------------------------------
A. Same
B. Equals
C. The code compiles, but nothing is displayed upon execution.
D. The code fails to compile.
<PREVIOUS || Main Page || NEXT >
GIVE YOUR ANSWER IN THE COMMENT BELOW
No comments:
Post a Comment