Given:
int a = 0;
int b = 10;
do {
a--;
++b;
} while (a < 5);
System.out.print(a + "," + b);
What is the result?
A. 5,6
B. 5,5
C. 6,5
D. 6,6
Execution:
If we put SOUT in following code:
++a;
System.out.println("A="+a+" B="+b);
} while (a < 5);
On Each loop following will be result:
A=1 B=9
A=2 B=8
A=3 B=7
A=4 B=6
A=5 B=5
Result:
B. 5,5
int a = 0;
int b = 10;
do {
a--;
++b;
} while (a < 5);
System.out.print(a + "," + b);
What is the result?
A. 5,6
B. 5,5
C. 6,5
D. 6,6
Execution:
If we put SOUT in following code:
++a;
System.out.println("A="+a+" B="+b);
} while (a < 5);
On Each loop following will be result:
A=1 B=9
A=2 B=8
A=3 B=7
A=4 B=6
A=5 B=5
Result:
B. 5,5
No comments:
Post a Comment