---
title: "Return Type — AP Computer Science A Definition & Guide"
description: "Return type is the data type a Java method gives back when called."
canonical: "https://fiveable.me/ap-comp-sci-a/key-terms/return-type"
type: "key-term"
subject: "AP Computer Science A"
unit: "Unit 3"
---

# Return Type — AP Computer Science A Definition & Guide

## Definition

In AP Computer Science A, the return type is the data type declared in a method's header (like int, double, boolean, String, or void) that tells the compiler what kind of value the method sends back to its caller, with void meaning the method returns nothing.

## What It Is

The return type is the part of a [method header](/ap-comp-sci-a/key-terms/method-header "fv-autolink") that promises what kind of value the [method](/ap-comp-sci-a/unit-3/abstraction-and-program-design/study-guide/o9VgVeIpKRYZ7N7rXfUz "fv-autolink") hands back. In `public int getArea()`, the return type is `int`, so somewhere inside that method there must be a `return` statement that produces an int. If a method has the return type `void`, it returns nothing at all. It just does something (like changing an object's state or printing output) and then control goes back to the caller.

Think of a method like a vending machine. The [parameters](/ap-comp-sci-a/unit-4/recursion/study-guide/p4D3YegZCLwQ3KJVvsd4 "fv-autolink") are what you put in, and the return type is the contract about what comes out. A method declared to return `double` cannot hand you a String, and a `void` method hands you nothing, so writing `int x = someVoidMethod();` is a compile-time error. The return type sits right before the method name in the header, after any modifiers like `public static`, which is why reading method headers carefully is one of the fastest skills you can build for the exam.

## Why It Matters

Return types show up the moment you start calling methods on [objects](/ap-comp-sci-a/key-terms/object "fv-autolink") early in the course, and they never leave. You need them to write your own classes (every [accessor method](/ap-comp-sci-a/unit-3/writing-methods/study-guide/rtuMpRFmidkpYTzvDndS "fv-autolink") like `getBalance()` declares what it returns), to trace code in multiple-choice questions, and to write correct method headers on every single FRQ. The Methods and Control Structures FRQ literally gives you a method header and expects you to honor its return type, so if the header says `public static int`, your solution must return an int on every path through the code. Getting the return type wrong is one of the most common ways to lose easy FRQ points.

## Connections

### [Method Header (Units 2 and 5)](/ap-comp-sci-a/key-terms/method-header)

The return type is one of the pieces of a method header, alongside the [access modifier](/ap-comp-sci-a/key-terms/access-modifier "fv-autolink"), method name, and parameter list. When a question shows you `public static void sortAndTruncate(ArrayList<Integer> data, int maxSize)`, the `void` tells you immediately that this method changes things rather than producing a value.

### Mutable Objects and Object State (Units 2 and 5)

Void methods often still do real work by mutating an object or array passed in as a [parameter](/ap-comp-sci-a/key-terms/parameter "fv-autolink"). A method like `removeOutliers(int[] data, int min, int max)` returns nothing, but the array the caller passed in is permanently changed. The return type tells you whether to look for a returned value or a side effect.

### Data Types and Casting (Unit 1)

Return types follow the same rules as variable types. If a method returns a double, you can't store the result in an int without a cast, and integer division inside a method that returns a double can silently produce the wrong answer. Type rules from [Unit 1](/ap-comp-sci-a/unit-1 "fv-autolink") apply to every return statement you write.

## On the AP Exam

Multiple-choice questions love to hand you a class definition with a comment like "// Method to be implemented" and ask which method would correctly complete it. The right answer has to match three things at once. The return type must fit the value being returned, the return statement must actually return that type, and the method must compile. You'll also see questions where a void method modifies an array or ArrayList parameter, and you have to recognize that the "output" is the mutation, not a returned value. On FRQs, College Board gives you the exact method header to implement. If it says the method returns a boolean, every execution path needs to return a boolean, including the cases you might forget (like an empty array). Forgetting a return statement, or returning the wrong type, costs points even if your logic is right.

## Return Type vs Printing with System.out.println

Returning a value and printing a value are completely different things, and mixing them up is the classic beginner error. `return` sends a value back to the calling code where it can be stored in a variable or used in an expression. `System.out.println` just displays text on the screen and gives the caller nothing. A method with return type `int` that prints the answer instead of returning it will fail every test the grader runs, because the caller receives no value. On FRQs, if the header has a non-void return type, you must use a return statement, not a print statement.

## Key Takeaways

- The return type appears in the method header right before the method name and declares what data type the method gives back to its caller.
- A void return type means the method returns nothing, so you cannot store its result in a variable or use it in an expression.
- A method with a non-void return type must reach a return statement of that exact (or compatible) type on every possible path through the code.
- Void methods can still change things by mutating objects or arrays passed in as parameters, so check whether a method works by returning a value or by side effect.
- Returning a value is not the same as printing it; FRQ graders test what your method returns, not what it prints.
- When overriding a method in a subclass, the return type must be compatible with the superclass method's return type or the code won't compile.

## FAQs

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

The return type is the data type declared in a method header that specifies what kind of value the method sends back when called. For example, in `public double getBalance()`, the return type is double, so calling the method produces a double value.

### Is void a return type?

Yes. Void is a return type that means the method returns no value at all. You can't assign the result of a void method to a variable, but the method can still do work like printing or changing an object's state.

### Does a void method mean nothing happens?

No. Void methods often mutate the objects or arrays passed to them, so the change persists after the method ends. A method like `removeOutliers(int[] data, int min, int max)` returns nothing but permanently modifies the array the caller passed in.

### What's the difference between a return type and a parameter?

Parameters are the inputs a method receives, listed in parentheses in the header, while the return type is the single output the method gives back. A method can have many parameters but only one return type.

### Can two methods have the same name but different return types?

Not if their parameter lists are also identical, because Java distinguishes overloaded methods by parameters, not return type. Two methods with the same name and parameters but different return types will not compile, which is a common multiple-choice trap.

## Related Study Guides

- [3.6 Accessor Methods](/ap-comp-sci-a/unit-3/accessor-methods/study-guide/aGdfIlIw7aOvNseJG5R1)
- [3.5 Writing Methods](/ap-comp-sci-a/unit-3/writing-methods/study-guide/rtuMpRFmidkpYTzvDndS)

## Structured Data

```json
{"@context":"https://schema.org","@graph":[{"@type":"LearningResource","@id":"https://fiveable.me/ap-comp-sci-a/key-terms/return-type#resource","name":"Return Type — AP Computer Science A Definition & Guide","url":"https://fiveable.me/ap-comp-sci-a/key-terms/return-type","learningResourceType":"Concept explainer","educationalLevel":"AP® / High School","about":{"@id":"https://fiveable.me/ap-comp-sci-a/key-terms/return-type#term"},"audience":{"@type":"EducationalAudience","educationalRole":"student"},"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-type#term","name":"Return Type","description":"In AP Computer Science A, the return type is the data type declared in a method's header (like int, double, boolean, String, or void) that tells the compiler what kind of value the method sends back to its caller, with void meaning the method returns nothing.","url":"https://fiveable.me/ap-comp-sci-a/key-terms/return-type","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 type in AP Computer Science A?","acceptedAnswer":{"@type":"Answer","text":"The return type is the data type declared in a method header that specifies what kind of value the method sends back when called. For example, in `public double getBalance()`, the return type is double, so calling the method produces a double value."}},{"@type":"Question","name":"Is void a return type?","acceptedAnswer":{"@type":"Answer","text":"Yes. Void is a return type that means the method returns no value at all. You can't assign the result of a void method to a variable, but the method can still do work like printing or changing an object's state."}},{"@type":"Question","name":"Does a void method mean nothing happens?","acceptedAnswer":{"@type":"Answer","text":"No. Void methods often mutate the objects or arrays passed to them, so the change persists after the method ends. A method like `removeOutliers(int[] data, int min, int max)` returns nothing but permanently modifies the array the caller passed in."}},{"@type":"Question","name":"What's the difference between a return type and a parameter?","acceptedAnswer":{"@type":"Answer","text":"Parameters are the inputs a method receives, listed in parentheses in the header, while the return type is the single output the method gives back. A method can have many parameters but only one return type."}},{"@type":"Question","name":"Can two methods have the same name but different return types?","acceptedAnswer":{"@type":"Answer","text":"Not if their parameter lists are also identical, because Java distinguishes overloaded methods by parameters, not return type. Two methods with the same name and parameters but different return types will not compile, which is a common multiple-choice trap."}}]},{"@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 3","item":"https://fiveable.me/ap-comp-sci-a/unit-3"},{"@type":"ListItem","position":4,"name":"Return Type"}]}]}
```
