Method Signatures MCQ Practice

Question 1 of 10

A kiln class contains this method header. What is its Java method signature?

public static void soak(int celsius, int minutes)
  1. A. void soak(int, int)
  2. B. soak(celsius, minutes)
  3. C. soak(int, int)
  4. D. public soak(int celsius, int minutes)

Question 2 of 10

A studio kiln API documents only the methods below. The potter must set a firing target of 900 degrees and hold that temperature for 40 minutes. Which method should be selected?

Header Purpose
public static void heat(int celsius) sets a target temperature
public static void heat(int celsius, int minutes) sets a target and a hold time
public static double glaze(double mm) records glaze thickness
public static boolean ready() returns whether the kiln is at target
  1. A. heat(int)
  2. B. heat(int, int)
  3. C. glaze(double)
  4. D. ready()

Question 3 of 10

These headers are in the same class. Which header is used by the call glaze(1.2, false)?

public static void glaze(double mm)
public static void glaze(double mm, boolean matte)
  1. A. glaze(double), because the first argument is a double
  2. B. glaze(double, boolean), because the arguments are a double then a boolean
  3. C. Neither, because false cannot be an argument
  4. D. A glaze(boolean, double) header

Question 4 of 10

Why are these two headers allowed in the same kiln class?

public static int cones(int shelf)
public static double cones(double shelf)
  1. A. They have different return types, and return type is part of the signature.
  2. B. They have the same signature, which Java always allows.
  3. C. The parameter names are different, which creates two signatures.
  4. D. The ordered parameter types differ (int versus double), so the signatures differ.

Question 5 of 10

The methods below are in the same class. What text does this Java code display?

public static void chime()
{
    System.out.print("DING");
}

System.out.print("OPEN");
chime();
System.out.print("SHUT");
  1. A. DING
  2. B. OPENSHUT
  3. C. OPENDINGSHUT
  4. D. OPENDING

Question 6 of 10

The methods below are in the same class. What value is displayed?

public static void soak(int minutes)
{
    minutes += 15;
}

int hold = 20;
soak(hold);
System.out.print(hold);
  1. A. 35
  2. B. 20
  3. C. 15
  4. D. 0

Question 7 of 10

The methods below are in the same class. What value is displayed?

public static int soak(int minutes)
{
    minutes += 15;
    return minutes;
}

int hold = 20;
hold = soak(hold);
System.out.print(hold);
  1. A. 20
  2. B. 15
  3. C. 35
  4. D. 5

Question 8 of 10

The methods below are in the same class. What value is displayed?

public static int mix(int parts)
{
    return parts * 3;
}
public static double mix(double parts)
{
    return parts * 3.0;
}

System.out.print(mix(4));
  1. A. 12.0
  2. B. 12
  3. C. 4
  4. D. 3

Question 9 of 10

The methods below are in the same class. What value is displayed?

public static int soak(int minutes)
{
    minutes += 15;
    return minutes;
}

int hold = 20;
soak(hold);
System.out.print(hold);
  1. A. 35
  2. B. 20
  3. C. 15
  4. D. The code cannot compile.

Question 10 of 10

A void kiln method is declared as public static void chime(). Which statement about a call is true?

  1. A. int n = chime(); stores 0 in n.
  2. B. The call chime(); transfers control to the method, then continues with the next statement after it returns.
  3. C. chime() can be added to an int, as in 2 + chime().
  4. D. A void method never returns control to the caller.