Question 2 / 297:  What is the expected output?
public static void main(String[] args) {

boolean stmt1 = "champ" == "champ";

boolean stmt2 = new String("champ").equals(new String("champ"));

boolean stmt3 = "champ".toString()=="champ";

System.out.println(stmt1 && stmt2 && stmt3);

}

A  true
B  false
<< First < Previous Next > Last >>
Explanation:

== checks if they are referencing the same object, but equals() checks if they have the same value.

Exam Home Page
Ask
Courntey Hub
Start Test
Marion Cabalfin
Start Quiz
Copy and paste the following HTML code into your website or blog.
<iframe src="https://www.jobilize.com/embed/java-certification-questions" width="600" height="600" frameborder="0" marginwidth="0" marginheight="0" scrolling="yes" style="border:1px solid #CCC; border-width:1px 1px 0; margin-bottom:5px" allowfullscreen webkitallowfullscreen mozallowfullscreen> </iframe>