Which code fragment, when inserted at line n1, enables …

Given the code fragment:

Which code fragment, when inserted at line n1, enables the App class to print Equal?

Given the code fragment:

Which code fragment, when inserted at line n1, enables the App class to print Equal?

A.
Option A

B.
Option B

C.
Option C

D.
Option D



Leave a Reply 3

Your email address will not be published. Required fields are marked *


renko

renko

Answer: B
package q069;

public class App {

public static void main(String[] args) {
String str1 = “Java”;
String str2 = new String(“Java”);
//line n1
if (str1.equalsIgnoreCase(str2)){
System.out.println(“Equal”);
} else {
System.out.println(“Not Equal”);
}
}
}
/* Output:
Equal
*/