Exam Permalink:
https://www.jobilize.com/java-certification-questions
Question Permalink:
https://www.jobilize.com/java-objects-comparison
Question 1 / 297:  What is the expected output?
public static void main(String[] args) {

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

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

boolean stmt3 = new String("champ") == new String("champ");

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

}

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

Stmt 1 would evaluate to true because of the string constant pool.

Stmt 2 would evaluate to false, because they are two different objects.

Stmt 3 would evaluate to also false , because they are two different objects.

Exam Home Page
https://www.jobilize.com/java-certification-questions

Oracle Certified Professional Java Programmer

Author:

Access: Public Instant Grading

Ask
George Turner
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>