Given:
What is the result?
A. 2 4 6 8 10 12
B. 2 4 6 8 10 12 14
C. Compilation fails
D. The program prints multiple of 2 infinite times
E. The program prints nothing
Given:
What is the result?
A. 2 4 6 8 10 12
B. 2 4 6 8 10 12 14
C. Compilation fails
D. The program prints multiple of 2 infinite times
E. The program prints nothing
public class MyClass {
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 MyClass().displaySeries();
}
}
for me it print nothing when I comment out the line flag = false; But if i did not comment this line it throws the compilation error.
The correct answer is E