Hi,
I am new to this forum.I am preparing for scjp5.The following question is from K&B chapter 4 Question no.5.
class Foozit{
public static void main(
String args[]){
Integer x = 0;
Integer y = 0;
for(Short z =0; z < 5; z++)
if((++x > 2) || (++y > 2));
x++;
System.out.println(x + " " + y);
}
}
What is the result?
A. 5 1
B. 5 2
C. 5 3
D. 8 1
E. 8 2
F. 8 3
G. 10 2
H. 10 3
The answer marked in the K&B is E.But when I compiled and run this program I got the result as 6 2.
Here,after the if statement the x is not an expression just a postincrement of x.(Is it because of that?)
Please correct me if I am wrong?
Thanks
Neju.