---
title: "Return Statement — AP Comp Sci A Definition & Exam Guide"
description: "A return statement ends a method and sends a value back to the caller. Learn how return types, void methods, and recursion show up on the AP CSA exam."
canonical: "https://fiveable.me/ap-comp-sci-a/key-terms/return-statement"
type: "key-term"
subject: "AP Computer Science A"
unit: "Unit 2"
---

# Return Statement — AP Comp Sci A Definition & Exam Guide

## Definition

In AP Computer Science A, a return statement immediately ends a method's execution and sends a value back to the line of code that called it; the value's type must match the return type declared in the method header, and void methods return no value at all.

## What It Is

A return statement does two jobs at once. First, it hands a value back to whoever called the [method](/ap-comp-sci-a/unit-3/abstraction-and-program-design/study-guide/o9VgVeIpKRYZ7N7rXfUz "fv-autolink"). Second, it immediately stops the method, even if there's more code below it. When Java hits `return`, control jumps straight back to the call site, and the [method call](/ap-comp-sci-a/key-terms/method-call "fv-autolink") expression gets replaced by the returned value. So if `getBalance()` returns 250.0, the call `double b = account.getBalance();` behaves as if you wrote `double b = 250.0;`.

The value you return has to match the return type in the method header. A method declared `public int countDown(int n)` must return an `int` on every possible path through the method. If the header says `void`, the method returns nothing, and you can still write a bare `return;` to exit early. Think of a [non-void method](/ap-comp-sci-a/unit-1/calling-void-method-with-parameters/study-guide/QVWxxGeVjbIbLpC10d1Y "fv-autolink") as a vending machine. You call it, it does its work, and it must hand something back. A void method is more like flipping a light switch. It does something, but nothing comes back to you.

## Why It Matters

Return statements thread through almost the entire AP CSA course. You start using them in [Unit 2](/ap-comp-sci-a/unit-2 "fv-autolink") when you call non-void methods on [objects](/ap-comp-sci-a/key-terms/object "fv-autolink") and have to do something with the result (store it, print it, or use it in an expression). In Unit 5 you flip to the other side and write your own methods, where every non-void method you write on an FRQ needs a correct return statement or you lose points. By Unit 10, return statements are the engine of recursion, because each recursive call returns a value that the previous call uses to build its own answer. The exam constantly tests whether you can trace what a method call evaluates to, and that's entirely a question about what gets returned.

## Connections

### Method header and return type (Units 2 & 5)

The [method header](/ap-comp-sci-a/key-terms/method-header "fv-autolink") is a promise and the return statement keeps it. If the header declares `public int getCount()`, every path through the method must return an int. Mismatching the declared return type and the returned value is a compile-time error the MCQ section loves to test.

### Void methods (Unit 5)

Void is the opposite case. A void method produces an effect (like printing or changing an instance variable) but returns no value, so writing `int x = someVoidMethod();` won't [compile](/ap-comp-sci-a/key-terms/compile "fv-autolink"). You can still use a plain `return;` inside a void method to bail out early.

### Recursion (Unit 10)

Recursive methods are basically return statements stacked on top of each other. In `return countDown(n - 1);` each call waits for the deeper call to return, then passes that value back up the chain. [Tracing](/ap-comp-sci-a/key-terms/tracing "fv-autolink") what a recursive method returns is one of the most common hard MCQs on the exam.

### Data types (Unit 1)

The return type is just a data type attached to a method. Everything you know about int vs. double vs. String vs. boolean applies, including widening (returning an int where a double is expected is fine, but not the reverse).

## On the AP Exam

Multiple choice questions test return statements two main ways. One, they give you a method and ask what a specific call evaluates to, which means tracing the code until you hit a return. Two, they test the rules themselves, like what's required to call a non-void method or what happens when `getBalance()` is called from inside another method (the call evaluates to the returned value, which the caller can use). Recursion questions raise the stakes, since you have to track returns flowing back up through multiple stacked calls. On the FRQ side, you'll write methods with declared return types, like the 2017 Phrase class question, where methods access and modify a string and hand results back. Two habits earn points there. Return the right type on every path, and remember that `return` exits the method instantly, which is a clean way to stop a loop the moment you find what you're searching for.

## Return Statement vs System.out.println (printing)

Printing and returning are completely different, and mixing them up costs FRQ points every year. `System.out.println` displays a value on the screen and gives nothing back to the program. `return` sends a value back to the calling code, where it can be stored in a variable or used in an expression, and it may never appear on screen at all. If an FRQ asks you to write a method that returns a String and you print it instead, you don't earn the point. A quick check is the method header. If the return type isn't void, the method needs a return statement, not a print statement.

## Key Takeaways

- A return statement immediately ends the method and sends a value back to the exact spot where the method was called.
- The returned value's type must be compatible with the return type declared in the method header, and every possible path through a non-void method must reach a return.
- A method call to a non-void method evaluates to its returned value, so `account.getBalance()` can be stored in a variable or used directly in an expression.
- Returning is not printing; `return` hands a value to the caller, while `System.out.println` only displays it, and FRQs grade you on returning.
- Void methods return nothing, but you can still use a bare `return;` to exit one early.
- In recursion, each call's return value feeds the call above it, so tracing returns up the call stack is how you find what a recursive method evaluates to.

## FAQs

### What is a return statement in AP Computer Science A?

A return statement ends a method's execution and sends a value back to the code that called it. The value must match the return type declared in the method header, like `int` or `String`.

### Is return the same as printing in Java?

No. `return` passes a value back to the caller so the program can use it, while `System.out.println` only displays text and gives nothing back. On FRQs, if the method header has a non-void return type, you must return, not print.

### Does code after a return statement still run?

No. The method stops the instant a return executes, and control jumps back to the caller. Unreachable code directly after a return won't even compile in Java, and an early return is a legit way to exit a loop the moment you find your answer.

### Do void methods need a return statement?

No, void methods don't require one because they return no value. You're allowed to write a bare `return;` to exit a void method early, but you can never return an actual value from it.

### How does a return statement work in a recursive method?

Each recursive call pauses and waits for the deeper call's return value. In `return countDown(n - 1);`, the base case (`return 0;` when n hits 0) returns first, and that value gets passed back up through every waiting call until the original caller gets the result.

## Related Study Guides

- [2.7 While Loops](/ap-comp-sci-a/unit-2/while-loops/study-guide/7qGsGOh1UKALAWpJhZOi)
- [2.3 If Statements and Control Flow](/ap-comp-sci-a/unit-2/if-statements-and-control-flow/study-guide/IbxsFeJQ5T1FNNBEWErO)
- [3.6 Accessor Methods](/ap-comp-sci-a/unit-3/accessor-methods/study-guide/aGdfIlIw7aOvNseJG5R1)
- [1.10 Calling a Non-Void Method](/ap-comp-sci-a/unit-1/calling-non-void-method/study-guide/gXkdn6sNrkDRHZsCVN1x)

## Structured Data

```json
{"@context":"https://schema.org","@graph":[{"@type":"LearningResource","@id":"https://fiveable.me/ap-comp-sci-a/key-terms/return-statement#resource","name":"Return Statement — AP Comp Sci A Definition & Exam Guide","url":"https://fiveable.me/ap-comp-sci-a/key-terms/return-statement","learningResourceType":"Concept explainer","educationalLevel":"AP / High School","about":{"@id":"https://fiveable.me/ap-comp-sci-a/key-terms/return-statement#term"},"audience":{"@type":"EducationalAudience","educationalRole":"student"},"dateModified":"2026-06-11T00:50:33.497Z","isPartOf":{"@type":"Collection","name":"AP Computer Science A Key Terms","url":"https://fiveable.me/ap-comp-sci-a/key-terms"},"publisher":{"@type":"Organization","name":"Fiveable","url":"https://fiveable.me"}},{"@type":"DefinedTerm","@id":"https://fiveable.me/ap-comp-sci-a/key-terms/return-statement#term","name":"Return Statement","description":"In AP Computer Science A, a return statement immediately ends a method's execution and sends a value back to the line of code that called it; the value's type must match the return type declared in the method header, and void methods return no value at all.","url":"https://fiveable.me/ap-comp-sci-a/key-terms/return-statement","inDefinedTermSet":{"@type":"DefinedTermSet","name":"AP Computer Science A Key Terms","url":"https://fiveable.me/ap-comp-sci-a/key-terms"}},{"@type":"FAQPage","mainEntity":[{"@type":"Question","name":"What is a return statement in AP Computer Science A?","acceptedAnswer":{"@type":"Answer","text":"A return statement ends a method's execution and sends a value back to the code that called it. The value must match the return type declared in the method header, like `int` or `String`."}},{"@type":"Question","name":"Is return the same as printing in Java?","acceptedAnswer":{"@type":"Answer","text":"No. `return` passes a value back to the caller so the program can use it, while `System.out.println` only displays text and gives nothing back. On FRQs, if the method header has a non-void return type, you must return, not print."}},{"@type":"Question","name":"Does code after a return statement still run?","acceptedAnswer":{"@type":"Answer","text":"No. The method stops the instant a return executes, and control jumps back to the caller. Unreachable code directly after a return won't even compile in Java, and an early return is a legit way to exit a loop the moment you find your answer."}},{"@type":"Question","name":"Do void methods need a return statement?","acceptedAnswer":{"@type":"Answer","text":"No, void methods don't require one because they return no value. You're allowed to write a bare `return;` to exit a void method early, but you can never return an actual value from it."}},{"@type":"Question","name":"How does a return statement work in a recursive method?","acceptedAnswer":{"@type":"Answer","text":"Each recursive call pauses and waits for the deeper call's return value. In `return countDown(n - 1);`, the base case (`return 0;` when n hits 0) returns first, and that value gets passed back up through every waiting call until the original caller gets the result."}}]},{"@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"AP Computer Science A","item":"https://fiveable.me/ap-comp-sci-a"},{"@type":"ListItem","position":2,"name":"Key Terms","item":"https://fiveable.me/ap-comp-sci-a/key-terms"},{"@type":"ListItem","position":3,"name":"Unit 2","item":"https://fiveable.me/ap-comp-sci-a/unit-2"},{"@type":"ListItem","position":4,"name":"Return Statement"}]}]}
```
