hello all,
I have read the chapter 4, and done the
test, but there is one question (nr 8) that sais:
Place the fragments into the code to produce the output 33. Note, you must use each fragment
exactly once.
CODE:
class Incr {
public static void main(
String[] args) {
Integer x = 7;
int y = 2;
x ___ ___;
___ ___ ___;
___ ___ ___;
___ ___ ___;
System.out.println(x);
}
}
FRAGMENTS:
y y y y y x x
-= *= *= *=
And the solution they gave is:
class Incr {
public static void main(String[] args) {
Integer x = 7;
int y = 2;
x *= x; // x = 49
y *= y; // y = 25
y *= y; // y = 625
x -= y; // x = -576
System.out.println(x);
}
}
I put as comments the rezults of the operation they gave in the book, and as you can see the result is not 33, as they want.
So, is the test question wrong, or are the fragments given wrong ?
What do you think ?
Thank you