Given: What is the result?
A.
The program prints nothing
B.
2 4 6 8 10 12
C.
2 4 6 8 10 12 14
D.
Compilation fails
E.
The program prints multiple of 2 infinite times
Given: What is the result?
Given: What is the result?
A.
The program prints nothing
B.
2 4 6 8 10 12
C.
2 4 6 8 10 12 14
D.
Compilation fails
E.
The program prints multiple of 2 infinite times
Answer: A
Code question:
public class Series {
private boolean flag;
public void displaySeries() {
int num = 2;
while (flag) {
if (num % 7 == 0)
flag = false;
System.out.print(num);
num += 2;
}
}
public static void main(String[] args) {
new Series().displaySeries();
}
}
Output:
run:
BUILD SUCCESSFUL (total time: 0 seconds)