Submitted by c-admin on Tue, 06/04/2019 - 21:58
Consider the following code for the main() method:
public static void main(String[] args) throws Exception{
int i = 1, j = 10;
do {
if (i++ > --j) continue;
} while (i < 5);
System.out.println("i=" + i + " j=" + j);
}
What will be the output when the above code is executed?
Select 1 option
A. i=6 j=6
B. i=5 j=6
C. i=5 j=5
D. i=6 j=5
E. None of these.
Submitted by c-admin on Tue, 06/04/2019 - 21:53
What will the following code print when compiled and run
public class TestClass {
public static void main(String[] args){
while(int k = 5; k<7){
System.out.println(k++);
}
}
}
Select 1 option
A. 5
6
B. 5
6
7
C. It will keep printing 5.
D. It will not compile.
E. It will throw an exception at run time.
Pages