Skip to main content

Return Type in AP Computer Science A

In AP Computer Science A, a return type is the data type in a method header, placed right before the method name, that tells you what kind of single value the method sends back to the caller. A method that sends nothing back uses the keyword void instead.

This definition is part of Fiveable's AP Computer Science A review, which also has guided practice questions.

Verified for the 2027 AP Computer Science A exam•Last updated October 2026

What is the Return Type?

The return type is the part of a method header that promises what kind of value the method will hand back when it finishes. In public double getArea(), the return type is double. Anyone who calls getArea() gets a double back, and they can store it, print it, or use it in a bigger expression.

The CED splits methods into two kinds based on this one slot. A void method has the keyword void where the return type would go, and it does not return a value (EK 3.5.A.1). A non-void method puts a real return type there, like int, boolean, double, or String, and it returns exactly one value (EK 3.5.A.2). Inside a non-void method, the return expression has to be compatible with the declared return type. Java evaluates that expression and sends a copy of the result back, which is called return by value (EK 3.5.A.3). Think of the return type as the label on a package. The return statement is what actually goes in the box, and the two have to match.

Why the Return Type matters in AP® Computer Science A

Return type lives in Unit 3: Class Creation, under Topic 3.5 Writing Methods, and it supports learning objective 3.5.A. That objective asks you to develop code that defines an object's behaviors through methods and to determine the result of calling those methods. You can't do either without knowing the return type. It tells you whether a method call produces a value you can use (int total = obj.getTotal();) or just does an action (obj.reset();). On the exam, picking the right return type is how you show you understand what a method is for. A method that calculates something needs a non-void return type. A method that only changes state usually gets void. That decision shows up in every class-writing FRQ, where getting the header wrong can cost you points before you even write the method body.

How the Return Type connects across the course

Return Statement (Unit 3)

The return type is the promise in the header, and the return statement keeps that promise in the body. A method declared int must reach a return with an int-compatible value. Once that return runs, control jumps back to the caller, and any code after it never executes (EK 3.5.A.4).

Parameters (Unit 3)

Parameters are what goes into a method, and the return type is what comes out. In public double area(double length, double width), two doubles go in and one double comes back. Reading a header as "inputs on the right, output on the left" makes signature questions much faster.

Mutator Methods and Side Effects (Unit 3)

Mutator methods usually have a void return type because their job is to change instance variables, not to report a value. That change is a side effect. So the return type gives you a quick clue. void usually means the method changes something, and a non-void type usually means it computes or reports something.

Data Type (Units 1 and 3)

A return type is just a data type used in a specific spot. Everything you know about primitives like int, double, and boolean applies here. That includes the fact that a double method can return an int value (it widens), but an int method can't return a double without a cast.

Is the Return Type on the AP® Computer Science A exam?

On multiple choice, return type questions usually come in a few flavors. You might pick out which header is a void method or which is a non-void method. You might choose the best signature for a task, like a method that calculates a rectangle's area (it should take dimensions as parameters and return a numeric type like double). Or you might name the kind of method that "calculates and sends back" a value, such as a GPA, which is a non-void method. You'll also trace code and decide what a method call evaluates to, or spot a compile error when a return value doesn't match the declared type. No released FRQ has used the term "return type" verbatim. Still, every class-design FRQ makes you write method headers from a description. The skill is to read the prompt, ask "does this method give back a value, and what kind?", and then write void or the correct type before the method name.

The Return Type vs Return Statement

The return type is a declaration in the method header (like int in public int getScore()), and it says what kind of value will come back. The return statement is a line of code in the method body (like return score;) that actually sends the value and ends the method. Every non-void method needs both, and they must agree. A void method has no return type, and if it uses return at all, it's a bare return; with no value, just to exit early.

Key things to remember about the Return Type

  • The return type is written in the method header right before the method name, and it tells you what kind of value the method sends back.

  • A void method uses the keyword void instead of a return type and does not return any value.

  • A non-void method returns exactly one value, and that value must be compatible with the declared return type.

  • Java uses return by value, which means the method evaluates the return expression and sends a copy of the result back to the caller.

  • When a return statement runs, control goes back to where the method was called, so any code after it in that path never executes.

  • If a task says a method should calculate, find, or report something, it almost always needs a non-void return type rather than void.

Frequently asked questions about the Return Type

What is a return type in AP Computer Science A?

It's the data type in a method header, written right before the method name, that says what kind of value the method returns. In public boolean isEmpty(), the return type is boolean, so calling isEmpty() gives you a true or false value.

Is void a return type?

Sort of. void sits in the return type slot, but it means the method returns nothing. The CED describes a void method as having the keyword void in place of a return type (EK 3.5.A.1), and a non-void method as having a real return type there (EK 3.5.A.2).

Can a void method use the return keyword?

Yes. A void method can use return; with no value to exit early and send control back to the caller. It just can't return a value, so return 5; inside a void method won't compile.

What's the difference between return type and return statement?

The return type is in the header and declares what kind of value comes back, like double. The return statement is in the body and actually sends the value, like return length * width;. In a non-void method, the returned value must be compatible with the return type.

Can a method with a double return type return an int?

Yes. An int value is compatible with double because Java automatically widens it, so return 3; in a double method returns 3.0. The reverse doesn't work, because an int method can't return a double without an explicit cast.