1.09 Method Signatures
Identify return types, method names, and parameters from method signatures to understand what a method does and what it needs.
1. Reference Guide
A method’s signature decides which method Java runs. Knowing exactly what is (and is not) in a signature is the key to reading APIs and writing overloaded methods.
Key Topics
| Term | Definition | Example | College Board Requirement |
|---|---|---|---|
| Method | A named block of code that only runs when it is called. | add(3, 4); |
Unit 1, Topic 1.9: runs only when called |
| Method header | The first line of a method: modifiers, return type, name, parameter list. | public static int add(int a, int b) |
— |
| Method signature | Method name + ordered list of parameter types (AP scope). No parameters means an empty list. | add(int, int), reset() |
Unit 1, Topic 1.9, p. 41: “the method name and the ordered list” of parameter types |
| Parameter | A variable in the method header. It receives a value. | int a |
Unit 1, Topic 1.9: sets how many values, in what order, of what types |
| Argument | The actual value passed in the method call. | add(3, 4) (3 and 4) |
Unit 1, Topic 1.9: the values passed in the call |
| Return type | The type of value the method gives back, or void for none. Not part of the signature. |
int |
Unit 1, Topic 1.9: two methods cannot differ only by return type (Gosling et al., 2025, §§8.4.2, 8.4.9) |
| Overloading | Same method name, different parameter lists in one class. | add(int) and add(int, int) |
Unit 1, Topic 1.9: same name, different signatures; Java matches the call’s arguments |
| Procedural abstraction | Using a method by knowing what it does, not how it is written. | Math.abs(-5) |
Unit 1, Topic 1.9: use a method without knowing how it is written |
| Call by value | A primitive parameter gets a copy of the argument, so changing it does not change the original. | bump(x) leaves x alone |
Unit 1, Topic 1.9: a primitive parameter starts as a copy |
College Board column: paraphrased from the course and exam description (College Board, 2025); check exact wording and numbering in the CED.
What is in a Signature?
| Part of the header | Example | In the signature? |
|---|---|---|
| Access modifier | public |
No |
static keyword |
static |
No |
| Return type | int |
No |
| Method name | add |
Yes |
| Parameter types (in order) | int, int |
Yes |
| Parameter names | a, b |
No |
Picking the Right Method
- Count the arguments, then check order, then check types.
- Exact type match wins. If there is none, Java widens (
inttodouble). - Java never narrows on its own (
doubletointneeds a cast). - Same name + same parameter types + different return type = compile error.
2. Lesson Plan
Learning Objective: Identify the parts of a method signature, tell parameters from arguments, and predict which overload gets called.
Success Criteria: Given a method header, you can state its signature and say whether another method could legally overload it.
Tech Talk (5 minutes)
A method header has four parts, but Java only uses two of them to tell methods apart.
public static int add(int a, int b)
| Part | Example | Note |
|---|---|---|
| Access modifier | public |
Not part of the signature |
| Return type | int |
Not part of the signature |
| Method name | add |
Part of the signature |
| Parameter list | (int a, int b) |
Types and order are part of the signature |
Signature: add(int, int). Two methods can share a name only if their parameter lists differ. That is overloading.
3. Code Examples
A. Parameters vs arguments, and call by value
The ParamDemo class shows where parameters and arguments live, and that a primitive argument is copied.
Two words that get mixed up a lot:
public static void greet(String name, int times) // name and times are PARAMETERS
greet("Sam", 2); // "Sam" and 2 are ARGUMENTS
Code Runner Challenge
Run it, then change the argument to addFive and predict what main prints
View IPYNB Source
// CODE_RUNNER: Run it, then change the argument to addFive and predict what main prints
public class ParamDemo {
// name and times are parameters
public static void greet(String name, int times) {
for (int i = 0; i < times; i++) {
System.out.println("Hello, " + name + "!");
}
}
// number is a copy of whatever argument is passed in
public static void addFive(int number) {
number = number + 5;
System.out.println("Inside addFive: " + number);
}
public static void main(String[] args) {
greet("Sam", 2); // "Sam" and 2 are arguments
int score = 10;
addFive(score); // score is copied into number
System.out.println("Back in main: " + score); // still 10
}
}
ParamDemo.main(null);
B. Overload resolution
The OverloadDemo class has several show methods. Java picks one by looking at the number, order, and types of the arguments.
Common overload mistakes:
show(3, "a") // matches show(int, String)
show("a", 3) // matches show(String, int): order matters
half(9) // no half(int), so the int 9 widens to 9.0 for half(double)
Code Runner Challenge
Run it, then add a call that has no matching overload and read the compiler error
View IPYNB Source
// CODE_RUNNER: Run it, then add a call that has no matching overload and read the compiler error
public class OverloadDemo {
public static void show(int x) { System.out.println("show(int): " + x); }
public static void show(double x) { System.out.println("show(double): " + x); }
public static void show(String s) { System.out.println("show(String): " + s); }
public static void show(int x, String s) { System.out.println("show(int, String): " + x + s); }
public static void show(String s, int x) { System.out.println("show(String, int): " + s + x); }
public static double half(double x) { return x / 2; }
public static void main(String[] args) {
show(7); // exact match: show(int)
show(7.5); // exact match: show(double)
show("hi"); // exact match: show(String)
show(3, "a"); // show(int, String)
show("a", 3); // show(String, int): order matters
System.out.println(half(9)); // 4.5, the int 9 widens to 9.0
// show(true); // ERROR: no show(boolean) exists
}
}
OverloadDemo.main(null);
C. The return type is not part of the signature
The ReturnTypeDemo class has two legal total methods. A third one that changes only the return type would not compile.
Code Runner Challenge
Run it, then uncomment the illegal method and read the compiler error
View IPYNB Source
// CODE_RUNNER: Run it, then uncomment the illegal method and read the compiler error
public class ReturnTypeDemo {
public static int total(int a, int b) { return a + b; } // total(int, int)
// Same name + same parameters, only the return type differs:
// public static double total(int a, int b) { return a + b; } // compile error
public static double total(double a, double b) { return a + b; } // total(double, double), legal
public static void main(String[] args) {
System.out.println(total(2, 3)); // 5 -> total(int, int)
System.out.println(total(2.5, 3)); // 5.5 -> total(double, double)
}
}
ReturnTypeDemo.main(null);
4. Hacks & Practice Tasks
Grading Plan (1 Point Total)
| Part | Points | What earns the points |
|---|---|---|
| Popcorn | 0.15 | Three signatures written correctly, and four overload predictions made. |
| MCQ | 0.15 | 4 or 5 correct in the last saved answers. 0.1 for 3, 0.05 if every question was answered. |
| Homework: circle area | 0.15 | area(double) returns the correct circle area. |
| Homework: rectangle area | 0.15 | area(int, int) returns the correct rectangle area. |
| Homework: signature comments | 0.15 | Signature comment above each method is correct (name + parameter types only). |
| Homework: overload explanation | 0.15 | Comment for area(3) correctly says area(double) runs because the int widens to double. |
| Reflection | 0.1 | 0.05 each: explains the reasoning in the student’s own words and uses signature, parameter, or widening correctly. |
| Total | 1.0 |
How to Submit
Everything you turn in stays on this page, in its runners. There is no separate notebook to submit.
- Click 💾 on every code runner after your last change, including the examples.
- Check your MCQ answers. Your last saved answers are the ones sent.
- Click 📤 on both reflection boxes.
- Click Submit Code at the bottom of this page.
Write your own answers, not the sample code from the lesson.
Popcorn Hack (In-Class)
2-minute challenge: be the signature detective.
- Write the signature for each of the three headers.
- Predict which overload (A, B, C, or D) each of the four calls runs.
- Run it and compare your guesses with the real output.
Replace every "?" with your own answer, then click 💾.
Code Runner Challenge
Replace every "?" with your answer, then run it and compare
View IPYNB Source
// CODE_RUNNER: Replace every "?" with your answer, then run it and compare
//SignatureDetective
public class SignatureDetective {
// Part 1: write each signature (name + parameter types only)
// public int getScore(String name) ->
String sig1 = "?";
// public static double average(double a, double b) ->
String sig2 = "?";
// private void reset() ->
String sig3 = "?";
// Part 2: four overloads
public static String pick(int x) { return "A"; }
public static String pick(double x) { return "B"; }
public static String pick(int x, int y) { return "C"; }
public static String pick(String s) { return "D"; }
// Predict the letter each call prints BEFORE you run
String guess1 = "?"; // pick(4)
String guess2 = "?"; // pick(4.0)
String guess3 = "?"; // pick(4, 5)
String guess4 = "?"; // pick("4")
public static void main(String[] args) {
SignatureDetective d = new SignatureDetective();
System.out.println("Signatures: " + d.sig1 + " | " + d.sig2 + " | " + d.sig3);
System.out.println("Your guesses: " + d.guess1 + d.guess2 + d.guess3 + d.guess4);
System.out.println("Actual: " + pick(4) + pick(4.0) + pick(4, 5) + pick("4"));
}
}
SignatureDetective.main(null);
MCQ Check
5 questions. Use the tabs to move between them, and check an answer as many times as you need. Each check saves that answer, and your last saved answers are sent when you click Submit Code at the bottom of this page.
MCQ 1.09
Check each answer as many times as you need. Your last saved answers are the ones submitted.
Homework Hack
Task: Finish the two overloaded area methods. Above each method, write its signature in a comment. Then run the calls in main. For the third call, area(3), write a one-line comment explaining which overload runs and why. Click 💾 when you finish: this runner is your homework submission.
Code Runner Challenge
Finish the overloaded methods, fill in the comments, then run it
View IPYNB Source
// CODE_RUNNER: Finish the overloaded methods, fill in the comments, then run it
public class HomeworkStarter {
// Signature: ?
public static double area(double radius) {
return 0.0; // TODO: circle area (use Math.PI)
}
// Signature: ?
public static int area(int width, int height) {
return 0; // TODO: rectangle area
}
public static void main(String[] args) {
System.out.println(area(3.0)); // expected: ~28.27
System.out.println(area(3, 4)); // expected: 12
System.out.println(area(3)); // predict first
// My answer for area(3): ?
}
}
HomeworkStarter.main(null);
Reflection
Answer both questions in full sentences, then click 📤 on each box to save your answer. Saved answers are sent when you click Submit Code at the bottom of this page.
Reflection #1
A classmate says int calc(int x) and double calc(int x) can both exist in one class because their return types differ. Explain why Java rejects this, using what a signature contains.
Reflection #2
In your homework, area(3) runs even though no area method takes a single int. Explain how Java chose the method, then describe what would change if you added area(int radius).
5. Lesson Revisions
Revision Made: Cut down wording to make concepts clearer and quicker to learn, and made the grading and assignment more accessible for AI grading of the popcorn hacks.
6. Feedback Evidence
Feedback Received: The lesson should be more concise and less repetitive. The popcorn hacks should be more interactive instead of a simple FRQ-style question and answer. The topic is relatively simple, so it does not need to be extensive or long.
7. LxD Cycle Process
Empathize: Students often include the return type, access modifier, or parameter names when identifying a signature. They may also use parameter and argument interchangeably, confuse overloading with overriding, or expect Java to choose an overload from the return type.
Define:
- POV: Beginning Java students need a consistent way to reduce a full method header to its name and ordered parameter types, because visually prominent words such as
public,static, andintcan distract from the parts Java uses to tell overloads apart. - Learning Issue: Students need to connect a call’s argument count, order, and compatible types to the parameter list before predicting which overload runs.
- Learning Goal: Students will reduce a method header to its signature, tell parameters from arguments, explain call by value, and predict which overloaded method a call runs.
Ideate:
- HMW Question: How might we make the signature-bearing parts of a method header visible while fading the parts that do not belong to the signature?
- HMW Question: How might we let students test an overload prediction before the compiler reveals the answer?
- Activity: Color-code several method headers, write each reduced signature, and match calls to overloads. Include one pair that differs only by return type and explain why it cannot compile.
Prototype:
- A reference guide, runnable Java examples, a signature-detective popcorn hack, an MCQ knowledge check, and a scaffolded area-method rubric.
- Students revise their predictions after seeing the runner output.
- Excellence means explaining why a call picks a given overload, not only getting the output right.
Test:
- Ask a partner to annotate one unfamiliar header and predict two calls without extra explanation.
- Record whether the partner used names, return types, or modifiers incorrectly.
- Revise the visual cue or example that caused the confusion.
- On submission, collect evidence from runner output, MCQ results, AI grading, and student explanations.
- After teaching, grading, and analysis, come back and revise the lesson to complete the teaching cycle for continuous improvement.
8. References
College Board. (2025). AP Computer Science A course and exam description [Effective fall 2025]. https://apcentral.collegeboard.org/media/pdf/ap-computer-science-a-course-and-exam-description-effective-fall-2025.pdf
Gosling, J., Joy, B., Steele, G., Bracha, G., Buckley, A., Smith, D., & Bierman, G. (2025). The Java language specification: Java SE 25 edition (Secs. 8.4.2, 8.4.9). Oracle. https://docs.oracle.com/javase/specs/jls/se25/html/jls-8.html#jls-8.4.2
Submit Assignment
Need to update a submission later? Open the submissions dashboard.