AP CSA Method Signatures Return Types

Method Signatures and Return Types in AP CSA

Understanding how to read and write method signatures is fundamental to the entire AP exam. Every FRQ gives you a method header and expects you to implement it correctly.

Anatomy of a Method Signature

public    int    add    (int a, int b)
^          ^      ^       ^
access   return  name  parameters
modifier  type

Return Types

Return type What the method returns Example
void Nothing — no return statement needed public void print()
int An integer value public int getAge()
double A decimal value public double getGPA()
boolean true or false public boolean isValid()
String A String object public String getName()

Common Return Mistakes

// ERROR: missing return in non-void method
public int getScore() {
    int score = 100;
    // forgot: return score;
}

// ERROR: returning wrong type
public int getScore() {
    return "100";  // can't return String from int method
}

// CORRECT
public int getScore() {
    return score;  // returns int, matches method signature
}
Overloading: Two methods can have the same name if their parameter lists differ (different types or count). The compiler picks the right one based on the arguments you pass.

📝 Practice Question 1

A method is declared as public boolean isEven(int n). Which of the following return statements is correct?

📝 Practice Question 2

What is the output of the following code?

public static int mystery(int x) {
    if (x > 10) {
        return x * 2;
    }
    return x + 1;
}
System.out.println(mystery(10));
System.out.println(mystery(11));
✅ Exam Tip: On FRQs, always check that your return type matches the method header given. A method declared public int that returns nothing (or returns a String) will lose points even if the logic is correct.

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]