Can someone explain why this happens?
sample quiz question
suppose that the following variable declarations have been made:
int i = 0, int k = 0; String s = "@"; Give the exact output produced by the following code fragments:
(a)
System.out.print(i==3); // I know this won't work
(b)
System.out.println("Ans: "+(j++)+(++j)+(j++)+(++J); // I don't understand why it gives 0224 and not 1234 :confused:
(c)
for (; k<3; k++) {
System.out.print(s);
s = s+s;
}
System.out.println(s); // I need to know why it returns 15 @ signs and not seven :confused:
Thanks for the help :)