1. Work through the above statements with pencil and paper, substituting results for calls.
2. Here is a method named twice, which returns the doubled value of its int parameter:
private int twice(int n) {
return 2 * n;
}
Here are some calls:
int n = 3;
int r;
r = twice(n);
r = twice(n + 1);
r = twice(n) + 1;
r = twice(3 + 2 * n);
r = twice(twice(n));
r = twice(twice(n + 1));
r = twice(twice(n) + 1);
r = twice(twice(twice(n)));
For each call, state the returned value.
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here