Leave a Reply 7

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


mrZ

mrZ

B

Chia

Chia

E

TM

TM

B note the ; after while() it keeps running and does not print anything

renko

renko

E

Tested:
public class Series {
public static void main(String[] args) {
int arr[] = {1, 2, 3};

for (int var : arr) {
int i 1;
while (i <= var);
System.out.println(i++);
}
// TODO code application logic here
}

}
Output:
Exception in thread "main" java.lang.RuntimeException: Uncompilable source code – variable i might not have been initialized
at Series.main(Series.java:7)

renko

renko

int i 1; must be int i = 1 => infinite loop: Answer:B