Return Type

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.

Verified for the 2027 AP Computer Science A examLast updated June 2026

What is the Return Type?

The return type is the part of a method header that promises what kind of value the method 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 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 the Return Type matters in AP Computer Science A

Return types show up the moment you start calling methods on objects early in the course, and they never leave. You need them to write your own classes (every accessor method 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. Return types also matter for overriding in inheritance, where a subclass method must have a compatible return type with the superclass method it overrides. Getting the return type wrong is one of the most common ways to lose easy FRQ points.

How the Return Type connects across the course

Method Header (Units 2 and 5)

The return type is one of the pieces of a method header, alongside the access modifier, 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. 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.

Overriding a Method (Unit 9)

When a subclass overrides a superclass method, the return type has to match (or be a compatible subtype). Two methods with the same name and parameters but clashing return types won't compile, which is a favorite trap in inheritance multiple-choice questions.

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 apply to every return statement you write.

Is the Return Type on the AP Computer Science A 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.

The 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 things to remember about the Return Type

  • 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.

Frequently asked questions about the Return Type

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.