Q.- 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?
A) if (str1.toLowerCase() == str2.toLowerCase())
B) if (str2.equals(str1.toLowerCase()))
C) str1.toLowerCase();
if(str1.equals(str2))
D) str1.toLowerCase();
if (str1 == str2)
⧪ please give your answer in a comment section.
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?
A) if (str1.toLowerCase() == str2.toLowerCase())
B) if (str2.equals(str1.toLowerCase()))
C) str1.toLowerCase();
if(str1.equals(str2))
D) str1.toLowerCase();
if (str1 == str2)
⧪ please give your answer in a comment section.
3 Comments
b
ReplyDeleteB
ReplyDeleteB
ReplyDelete