Lesson 1.9: Method Signatures | AP CSA
Lesson 1.9: Method Signatures
What you'll learn in this lesson
- 1.9.A. Identify the correct method to call based on a method signature, explain what parameters and arguments are, and describe how call-by-value works.
-
1.9.B. Distinguish between
voidand non-void methods, explain how method calls interrupt execution flow, and identify overloaded methods.
This lesson is part of the AP CSA Course and Exam Description (effective May 2027).
AP exam weight: Method signatures appear constantly — every time you call Math.abs, String.substring, or a class constructor, you are reading a signature. Expect 3–5 MCQs per exam that require you to match a call to its signature or trace through a call-by-value argument.
Key Vocabulary
| Term | Definition |
|---|---|
| method | A named block of code that only runs when called. |
| method signature | The method name plus the ordered list of parameter types; identifies a method uniquely within its class. |
| parameter | A variable declared in a method header; receives a copy of the argument when the method is called. |
| argument | The actual value passed to a method when it is called; must be compatible in number, order, and type with the parameter list. |
| call-by-value | Parameters receive copies of argument values; changes to parameters inside a method do not affect the caller's variables. |
| void method | A method with no return value; called as a standalone statement. |
| non-void method | A method that returns a value of the declared return type; the return value must be stored or used in an expression. |
| overloading | When a class has multiple methods with the same name but different signatures. |
What is a method?
A method is a named block of code that only runs when it is called (see the Java Language Specification §8.4 for full method declaration syntax). Procedural abstraction lets a programmer use a method by knowing what it does — from the signature and documentation — without needing to know how it was implemented internally.
Method signatures
A method signature identifies a method uniquely within a class. It consists of the method name plus the ordered list of parameter types. Return type is NOT part of the signature.
Anatomy of a Method Header
public static double average(int a, int b)
public static — access and type modifiers
double — return type (what the method gives back)
average — method name
(int a, int b) — parameter list (names + types of inputs)
Signature: average(int, int) — name + ordered parameter types only
Parameters vs Arguments
The Distinction
A parameter is a variable declared in the method header. It exists inside the method body.
An argument is the actual value passed when the method is called. Arguments must match parameters in number, order, and compatible type.
// Declaration: a and b are parameters
public static double average(int a, int b) { ... }
// Call: 10 and 6 are arguments
double result = average(10, 6);
Call-by-value
Call-by-Value Rule
When arguments are passed to a method, the parameters are initialized with copies of the argument values. Changing a parameter inside the method does NOT change the original variable in the calling code.
Example
public static void doubleIt(int n) {
n = n * 2; // changes the local copy only
}
int x = 5;
doubleIt(x);
System.out.println(x); // still prints 5
AP Trap: call-by-value for primitives
This is one of the most-tested traps in Unit 1. Students assume the original variable changes. It does not — x is still 5 after the call. The primitive value was copied; the method only modified its own local copy.
void vs non-void methods
The Distinction
A void method performs an action but returns no value. It is called as a standalone statement: System.out.println("hi");
A non-void method returns a value of the declared return type. The return value must be stored in a variable or used in an expression: double avg = average(10, 6);
AP Trap
Calling a non-void method and discarding the return value (e.g., average(10, 6); without storing it) compiles in Java but is almost always a logic error on the exam. Calling a void method as part of an expression is a compile error.
Execution flow: method calls interrupt sequencing
When a method is called, execution jumps into the method body. The calling code pauses. Once the method finishes (reaches return or the closing brace), control returns to the line immediately after the call.
Overloaded methods
Methods are overloaded when a class has multiple methods with the same name but different signatures. Math.abs(int x) and Math.abs(double x) are overloaded. Java picks the correct version based on the argument type at the call site.
Practice Questions
void methods is NOT true?void method does not have a return value.void method is called as a standalone statement, not as part of an expression.void method cannot take any parameters.System.out.println() is an example of a void method call.void keyword only affects the return type. A, B, and D are all accurate statements about void methods.public static void addTen(int n) {
n += 10;
}
int score = 50;
addTen(score);
System.out.println(score);
What is printed?
score after the method call before reading the options.n is modified inside the method.n is initialized with a copy of score (50). n += 10 changes the local copy to 60, but score in the calling code is never touched. Prints 50.public double computeTax(double income, int dependents)
public double computeTax(double income, int dependents)
double computeTax
computeTax(double, int) : double
computeTax(double, int)
I.
public int process(int x)II.
public double process(double x)III.
public int process(int x, int y)Which of the following is true about these methods?
(int), (double), and (int, int). Return type does not determine whether overloading is allowed.public static int triple(int n) {
return n * 3;
}
System.out.println("A");
int result = triple(4);
System.out.println("B");
System.out.println(result);
What is the output?
B
4
12
B
B
12
A
B
triple(4) which returns 12 and stores it in result, prints B, then prints 12. The method call happens silently between the two println statements. Result is A, B, 12 on separate lines.scale(double factor, int count). Which of the following calls will cause a compile error?I.
scale(2.0, 3)II.
scale(2, 3)III.
scale(3, 2.0)
scale(2.0, 3) — double and int match exactly. Valid. II: scale(2, 3) — int 2 widens to double 2.0. Valid. III: scale(3, 2.0) — first argument is fine (int widens to double), but second argument 2.0 is double and the parameter is int — narrowing without cast. Compile error.The Temperature Converter
A student writes two overloaded methods to convert temperatures.
public static double toCelsius(double fahrenheit) {
return (fahrenheit - 32) * 5.0 / 9.0;
}
public static double toCelsius(int fahrenheit) {
return (fahrenheit - 32) * 5.0 / 9.0;
}
double a = toCelsius(212.0);
double b = toCelsius(212);
double c = toCelsius(98.6);
Part A
toCelsius(98.6)?int version, because 98.6 rounds to 99.double version, because 98.6 is a double literal and matches that parameter type exactly.double version is the exact match. The int version would require a narrowing conversion, which Java does not do automatically.Part B
public static double toCelsius(double f, String unit), and calls toCelsius(100.0, "F"), which version is called?toCelsius(100.0, "F") has a double and a String, matching toCelsius(double, String) exactly. Any number of overloads is legal as long as signatures differ.Part C: Structured response
Explain in three to five sentences what “call-by-value” means in Java, why it prevents a method from changing the caller’s variable, and give a concrete example showing a variable’s value before and after a method call that attempts to modify it.
Scoring Rubric (4 points)
- +1: Defines call-by-value: the parameter is initialized with a copy of the argument value, not the variable itself.
- +1: Explains why the original does not change: modifying the parameter changes only the local copy inside the method; the original variable in the calling code is unaffected.
- +1: Provides a valid code example with a method that modifies its parameter.
-
+1: Shows the variable value is unchanged after the call (e.g., declares
int x = 5, calls a method that doesx *= 2on the parameter, then showsxis still 5).
Call-by-reference for objects
Call-by-value applies to primitive types. When an object is passed to a method, the parameter receives a copy of the reference (memory address), not a copy of the object itself. This means the method can change the object’s internal state by calling methods on it — but it cannot make the caller’s variable point to a different object. This distinction matters in Unit 3 when you write your own classes.
Get in Touch
Whether you're a student, parent, or teacher — I'd love to hear from you.
Just want free AP CS resources?
Enter your email below and check the subscribe box — no message needed. Students get daily practice questions and study tips. Teachers get curriculum resources and teaching strategies.
Message Sent!
Thanks for reaching out. I'll get back to you within 24 hours.
Prefer email? Reach me directly at [email protected]