The following program has a bug. You were expecting the output to be They are equal, but it was printing They are not equal instead.
class ExamPrep {
public static void main(String[] args){
String a = new String("Java");
String b = new String("Java");
if (a == b) { // LINE 5
System.out.println("They are equal");
} else {
System.out.println("They are not equal");
}
}
}
What can you replace LINE 5 with to fix the problem? Choose the correct answer:
A. if (a instanceof b) {
B. if ( (b)) {
C. if (a === b) {
D. if (a is b) {