Lesson 1.9: Method Signatures | AP CSA

Unit 1 · Lesson 1.9 · Conceptual

Lesson 1.9: Method Signatures

Reading time: 7–9 min·Practice: 6 exercises·Mastery: applied scenario

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 void and 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.

▶ Java Code Editor
Try It Yourself
Write real Java, hit Run, and your code executes on a live compiler. Output is checked automatically.
Tier 2 · AP Practice

Practice Questions

Which of the following statements about void methods is NOT true?
A. A void method does not have a return value.
B. A void method is called as a standalone statement, not as part of an expression.
C. A void method cannot take any parameters.
D. System.out.println() is an example of a void method call.
C. A void method can take any number of parameters. The void keyword only affects the return type. A, B, and D are all accurate statements about void methods.
Consider the following method and code segment.

public static void addTen(int n) {
    n += 10;
}
int score = 50;
addTen(score);
System.out.println(score);

What is printed?
Trace what happens to score after the method call before reading the options.
A. 50
B. 60
C. A compile error because the return value is discarded.
D. A run-time error because n is modified inside the method.
A. Call-by-value means 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.
Which of the following correctly identifies the signature of this method?

public double computeTax(double income, int dependents)
A. public double computeTax(double income, int dependents)
B. double computeTax
C. computeTax(double, int) : double
D. computeTax(double, int)
D. A method signature consists of the method name and the ordered list of parameter types only. Return type and access modifiers are not part of the signature. A includes everything. B omits parameters. C includes the return type, which is not part of the signature.
A class contains these three methods:

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?
A. This is a compile error because two methods cannot have the same name.
B. All three are valid because they are overloaded — they share the same name but have different signatures.
C. Only I and II are valid overloads; III is a compile error because its return type matches I.
D. I and III are a compile error because they have the same return type.
B. Overloading is legal as long as each method has a different signature (name + parameter types). All three have different parameter lists: (int), (double), and (int, int). Return type does not determine whether overloading is allowed.
Consider the following code.

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?
A. A
B
4
B. A
12
B
C. A
B
12
D. 12
A
B
C. Execution: prints A, calls 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.
A method has the signature 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)
A. III only
B. II and III only
C. I only
D. None — all three compile.
A. I: 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.
Tier 3 · AP Mastery Challenge

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

Which method version is called for toCelsius(98.6)?
A. The int version, because 98.6 rounds to 99.
B. Both versions are called and the results averaged.
C. A compile error because the argument is ambiguous.
D. The double version, because 98.6 is a double literal and matches that parameter type exactly.
D. Java selects the overloaded method whose parameter type best matches the argument. 98.6 is a double literal, so the double version is the exact match. The int version would require a narrowing conversion, which Java does not do automatically.

Part B

If the student adds a third version public static double toCelsius(double f, String unit), and calls toCelsius(100.0, "F"), which version is called?
A. The original double version, because the second argument is ignored.
B. The new two-parameter version, because the signature matches exactly.
C. A compile error because three overloads of the same method are not allowed.
D. A run-time error because the String argument is unexpected.
B. Java matches the call to the overloaded version whose signature fits the arguments. 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.

Extension · Beyond the Exam

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.

Typically responds within 24 hours

Message Sent!

Thanks for reaching out. I'll get back to you within 24 hours.

🏫 Welcome, fellow educator!

I offer curriculum resources, practice materials, and study guides designed for AP CS teachers. Let me know what you're looking for — whether it's classroom materials, a guest speaker, or Teachers Pay Teachers resources.

Email

[email protected]

📚

Courses

AP CSA, CSP, & Cybersecurity

Response Time

Within 24 hours

Prefer email? Reach me directly at [email protected]