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;
}
  1. In the method p1(), the return class is .

  2. In the method p1(), the variable y is called a(n). .

  3. In the statement a = p1(y); , which appears in main() y is called a(n). in this function call.

  4. After the above program is executed, the final value for a in main() is
  5. After the above program is executed, the final value for b in main() is
  6. After the above program is executed, the final value for c in main() is
  7. After the above program is executed, the final value for d in main() is
  8. After the above program is executed, the final value for y in main() is


Answers

  1. int
  2. value parameter
  3. argument
  4. 5
  5. 3
  6. 0
  7. 9
  8. 2