hi all,
Following is a piece of code from javabeat mock exam 14.
class TechnoSample {
public static void main (String args[]) {
int i = 0;
int j = 0;
label1: while (i++<5) {
label2:
for(;
{
label3:
do {
System.out.print(i + j);
switch (i+j++) {
case 0: continue label3;
case 1: continue label2;
case 2: continue label1;
case 3: break;
case 4: break label3;
case 5: break label2;
case 6: break label1;
default: break label1; } }
while (++j<5); } } }}
What is the result of attempting to compile and run the above program?
(1) Prints: 12457
(2) Prints: 02357
(3) Prints: 02356
(4) Prints: 1357
(5) Prints: 1356
(6) Runtime Exception
(7) Compiler Error
(8) None of the Above
Answer is 1. I often get wrong answers with such iterattion questions.Please anyone tell me how to apply the logic behind such type of questions?
[ June 19, 2007: Message edited by: ketki kalkar ]
[ June 19, 2007: Message edited by: ketki kalkar ]