What will be the output?
public class Test{
public static void main(String args[]){
int i = 1;
do{
i--;
}while(i > 2);
System.out.println(i);
}
}
public class Test{
public static void main(String args[]){
int i = 1;
do{
i--;
}while(i > 2);
System.out.println(i);
}
}
A. 1
B. 2
C. -1
D. 0
E. None of these
Answer: Option D
Related Questions on Flow Control
What is the purpose of the "if" statement in Java?
A. To execute a block of code conditionally
B. To create loops
C. To declare variables
D. To define methods
A. No output
B. Error
C. Hello
D. 5
Join The Discussion