CS110 Practice Quiz 6
More with Methods
 Choose the best alternative:
All questions refer to the Java code segment.
void main( ){
int y = 2;
int a = 1, b = 0, c = 0, d = 1;
a = p1(y);
b = p2(c);
d = p3(6);
}
public static int p1(int y){
y = y + 3;
return y;
}
public static int p2(int z){
z = 3;
return z;
}
public static int p3(int t){
return t + 3;
}
In the method
p1()
, the return class is
void
int
.
In the method
p1()
, the variable
y
is called a(n).
value parameter
argument
.
In the statement
a = p1(y);
, which appears in main()
y
is called a(n).
value parameter
argument
in this function call.
After the above program is executed, the final value for
a
in main() is
After the above program is executed, the final value for
b
in main() is
After the above program is executed, the final value for
c
in main() is
After the above program is executed, the final value for
d
in main() is
After the above program is executed, the final value for
y
in main() is
Answers
int
value parameter
argument
5
3
0
9
2