What is the result?

Given: What is the result?

Given: What is the result?

A.
ii = 1 ii = 2

B.
Compilation fails

C.
The program prints nothing

D.
The program goes into an infinite loop with no output

E.
The program goes to an infinite loop outputting: ii = 1 ii = 1



Leave a Reply 1

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


renko

renko

Answer: B

Code question:
public class MyClass {

public static void main(String[] args) {
while (int ii = 0; ii < 2) {
ii++;
System.out.println("ii = " + ii);
}
}
}
Output:
Exception in thread "main" java.lang.RuntimeException: Uncompilable source code – Erroneous tree type:
at MyClass.main(MyClass.java:4)