AP Computer Science A Practice Quiz: Method Signatures
Written by AP Content Team, Verified for 2026 AP Exams, Last updated: May 2026
Test your understanding with short quizzes. This quiz has 14 questions to check your progress.
Question 1 of 14
All Questions (14)
A) A named block of code that only runs when it is called.
B) A variable that stores different types of data.
C) A conditional statement that controls program flow.
D) A data structure for organizing information.
Correct Answer: A
The content explicitly states, 'A method is a named block of code that only runs when it is called.'
A) The method name and its return type.
B) The return type and the names of the parameter variables.
C) The method name and the ordered list of parameter types.
D) The method name and the number of lines of code it contains.
Correct Answer: C
The provided text specifies that 'A method signature for a method with parameters consists of the method name and the ordered list of parameter types.'
A) Method Calling
B) Return Value Storage
C) Procedural Abstraction
D) Parameter Typing
Correct Answer: C
The content defines this concept directly: 'Procedural abstraction allows a programmer to use a method by knowing what the method does even if they do not know how the method was written.'
A) The value is always an integer.
B) The value must be immediately printed to the screen.
C) The value's type matches the return type specified in the method's header.
D) The value is always null.
Correct Answer: C
As stated in the text, 'A non-void method returns a value that is the same type as the return type in the header.'
A) I
B) II
C) III
D) Either I or II would be correct.
Correct Answer: B
To correctly call a method, the arguments provided must match the ordered list of parameter types in the signature. Since the programmer has two integers, the signature `calculateSum(int a, int b)` is the correct one to call.
A) It is either automatically printed or discarded.
B) It must be converted to a string or an integer.
C) It must be stored in a variable or used as part of an expression.
D) It can only be used as a parameter for another method call.
Correct Answer: C
The text is explicit: 'To use the return value when calling a non-void method, it must be stored in a variable or used as part of an expression.'
A) Defining its signature.
B) Writing documentation for it.
C) Declaring its return type.
D) Calling the method.
Correct Answer: D
The content states that a method 'only runs when it is called.' Therefore, calling it is the action that triggers its execution.
A) createGreeting("Alice")
B) createGreeting(14, "Bob")
C) String message = createGreeting("Charlie", 9);
D) createGreeting("David", "10")
Correct Answer: C
The method signature requires a String first and an integer second, in that specific order. Option C provides the correct types in the correct order and correctly demonstrates one way to use a non-void method's return value by storing it in a variable.
A) Return Type Matching
B) Procedural Abstraction
C) Method Signature Definition
D) Variable Storage
Correct Answer: B
This scenario perfectly matches the definition of procedural abstraction, which 'allows a programmer to use a method by knowing what the method does even if they do not know how the method was written.'
A) The length of the method's code.
B) The ordered list of parameter types.
C) The names of the variables used inside the method.
D) The date the method was written.
Correct Answer: B
The method signature, which consists of the method name and the ordered list of parameter types, is used to uniquely identify a method. When methods share a name, the parameter list is what differentiates them.
A) The method cannot have any parameters.
B) The method must be called at least once.
C) The method returns a value.
D) The method's code is very complex.
Correct Answer: C
The text explicitly defines a non-void method as one that 'returns a value that is the same type as the return type in the header.'
A) The program will fail to compile.
B) The method will not execute because its result has nowhere to go.
C) The method will execute, but its return value will be discarded and lost.
D) The program will halt with a runtime error.
Correct Answer: C
The text states that to *use* a return value, it must be stored or used in an expression. It does not forbid calling the method without capturing the value. The method call is valid, so it will run, but the value it returns is not captured and is therefore lost.
A) It serves as a comment explaining the method's purpose.
B) It dictates the exact data types and sequence of arguments required for a valid method call.
C) It specifies the name of the variable that will store the method's return value.
D) It determines how much memory the method will use when it runs.
Correct Answer: B
The method signature acts as a strict contract for calling the method. The ordered list of parameter types defines exactly what kind of data, and in what order, must be provided for the call to be successful.
A) `printGrade`, because it is a void method and simpler to call.
B) `getGrade`, because it is a non-void method that returns a value which can be stored and used for the pass/fail check.
C) Either method is acceptable, as they both accomplish the same task.
D) `printGrade`, because the student ID is an integer.
Correct Answer: B
The goal is to use the grade in a subsequent logical check (pass/fail). The `getGrade` method is non-void and returns a `double`. According to the text, this return value can be 'stored in a variable or used as part of an expression,' which is required for the check. The `printGrade` method is `void` and does not return a value that can be used later.