Given the code fragment:
What is the result?
A.
A B C Work done
B.
A B C D Work done
C.
A Work done
D.
Compilation fails
Given the code fragment:
What is the result?
A.
A B C Work done
B.
A B C D Work done
C.
A Work done
D.
Compilation fails
Answer: C
package q089;
public class Test {
public static void main(String[] args) {
String[] arr = {“A”, “B”, “C”, “D”};
for (int i = 0; i < arr.length; i++) {
System.out.print(arr[i] +" ");
if (arr[i].equals("C")) {
continue;
}
System.out.println("Work done");
break;
}
}
}
/* Output
A Work done
*/