Oracle
1Z0-808 · Question #9
1Z0-808 Question #9: Real Exam Question with Answer & Explanation
Sign in or unlock 1Z0-808 to reveal the answer and full explanation for question #9. The question stem and answer options stay visible for context.
Working With Java Data Types
Question
Given the code fragment:
public class App {
public static void main(String[] args) {
String str1 = "Java";
String str2 = new String("Java");
//line n1
{
System.out.println("Equal");
} else {
System.out.println("Not Equal");
}
}
}
Which code fragment, when inserted at line n1, enables the App class to print Equal?
Options
- AString str3 = str2; if (str1 == str3)
- Bif (str1.equalsIgnoreCase(str2))
- CString str3 = str2; if (str1.equals(str3))
- Dif (str1.toLowerCase() == str2.toLowerCase())
Unlock 1Z0-808 to see the answer
You've previewed enough free 1Z0-808 questions. Unlock 1Z0-808 for full answers, explanations, the timed quiz mode, progress tracking, and the master PDF. Question stem and options stay visible so you can still see what's on the exam.
Topics
#String equality#equals() vs ==#equalsIgnoreCase()#object references