What is the result?

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

Download Printable PDF. VALID exam to help you PASS.

3 thoughts on “What is the result?

  1. 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();

    }
    }

  2. 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.

Leave a Reply

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


The reCAPTCHA verification period has expired. Please reload the page.