Programming Language Java Control Flow Question #2151
Single Choice Not Set

QWhat all gets printed when the following program is compiled and run?
public class Test{
      public static void main(String args[]){
            int i=0, j=2;
            do{
                  i=++i;
                  j--;
            }while(j>0);
            System.out.println(i);
      }
}

ID: #2151 Java Control Flow 1,645 views
Question Info
#2151Q ID
Not SetDifficulty
Java Control FlowTopic

Choose the Best Option

Click any option to instantly check if you're correct.

  • B 1
  • C 2
  • D The program does not compile because of statement "i=++i;"
Correct Answer

Explanation

2

Share This Question

Challenge a friend or share with your study group.