Skip to main content
The new Teacher Workspace is here. Your first 3 assignments are free. Try it →
A colleague sent you $30 off Fiveable. Get the annual plan for $99 →

Return value in AP Computer Science A

In AP Computer Science A, a return value is the result a non-void method sends back to the code that called it. It always matches the return type in the method header, and to use it you must store it in a variable or use it as part of an expression.

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

What is Return value?

A return value is what a method gives back after it runs. Think of a method like a vending machine. You put arguments in, it does its work, and a non-void method drops a result back out to you. That result is the return value.

The CED is specific about the rules. Per EK 1.9.B.2, a non-void method returns a value of the same type as the return type in its header. So public static double calculateArea(double length, double width) must hand back a double. To actually use that value, you have to catch it. Either store it in a variable (double area = calculateArea(3.0, 4.0);) or drop it into an expression (calculateArea(3.0, 4.0) * 2). A void method is the opposite case. Per EK 1.9.B.1, it has no return value, so it can't be called as part of an expression at all.

Why Return value matters in AP® Computer Science A

Return values live in Unit 1: Using Objects and Methods, in topic 1.9 Calling a Void Method With Parameters. They support two learning objectives. AP Comp Sci A 1.9.A asks you to pick the correct method to call from documentation and method signatures, and the return type is part of how you tell methods apart. AP Comp Sci A 1.9.B asks you to describe how to call methods, which includes knowing that void methods can't sit inside an expression (EK 1.9.B.1) and that non-void results must be stored or used (EK 1.9.B.2).

This matters well past Unit 1. Almost every FRQ asks you to write a method that returns something, or to call a provided method and use what it returns. If you misread a return type, your code won't compile in the grader's head, and you lose points.

How Return value connects across the course

Method Signature and Return Type (Unit 1)

The method header is a promise about what comes back. Reading public static int calculateSum(int a, int b) tells you the call produces an int before you ever see the body. That's procedural abstraction (EK 1.9.A.1). You know what a method returns without knowing how it computes it.

Return Statements When Writing Methods (Unit 3)

In Unit 1 you call methods and receive return values. Once you write your own classes, you produce them with a return statement. The type you return has to match the header you wrote. Same rule, just from the other side of the counter.

Boolean Return Values in Conditionals and Loops (Unit 2)

A method that returns a boolean can go straight into an if or while condition, like if (checker.isValid(str)). The 2018 FRQ Q3 StringChecker interface is built around exactly this kind of method, documented as "Returns true if str is valid." The return value becomes the decision.

Methods That Process Arrays and Collections (Unit 4)

Data-collection FRQs often hinge on methods that return a computed result from a structure. The 2021 FRQ Q4 ArrayResizer methods are documented with "Returns true..." on a two-dimensional array of integers. Your loops do the work, and the return value reports the answer.

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

Multiple choice: Expect stems that show a method header and ask which statement correctly calls it and stores the result in an appropriately typed variable. For example, given public static double calculateArea(double length, double width), the right answer stores the result in a double, not an int. Other stems list several signatures (a void printMessage, an int calculateSum, a double findAverage, a String formatName) and ask which call is legal inside an expression. The trap is usually the void method. Overloading questions also show up, where two analyze methods take different parameter types and return different types (int vs. double). You have to figure out which one runs and what type comes back.

FRQs: Released FRQs lean on return values constantly. The 2018 Q3 StringChecker uses a boolean-returning isValid. The 2019 Q2 StepTracker, the 2021 Q4 ArrayResizer, and the 2022 Q3 Review questions all ask you to write or use methods whose documentation says what they return. What you have to do is compute the right value, return the right type, and use helper methods' return values instead of ignoring them.

Return value vs Printing output (System.out.println)

Printing shows text on the screen for a human to read. Returning hands a value back to the calling code so the program can keep using it. A method that prints a number but doesn't return it gives the caller nothing to store. If an FRQ says "returns," you need a return statement, and printing instead won't earn the point.

Key things to remember about Return value

  • A return value is the result a non-void method sends back to the code that called it.

  • The return value always has the same type as the return type written in the method header.

  • To use a return value, you must store it in a variable or use it inside an expression, otherwise it is simply lost.

  • A void method has no return value, so it cannot be used as part of an expression or assigned to a variable.

  • Returning a value is not the same as printing it, and FRQs that say "returns" require an actual return statement.

  • Reading the return type in a method signature lets you know what a call produces without seeing how the method works.

Frequently asked questions about Return value

What is a return value in AP Computer Science A?

It's the result a non-void method gives back to its caller after running. Per EK 1.9.B.2, it matches the return type in the method header, and you use it by storing it in a variable or placing it in an expression.

Can you store the result of a void method in a variable?

No. A void method has no return value (EK 1.9.B.1), so a line like int x = printMessage("hi"); won't compile. Void methods are called as standalone statements.

What's the difference between returning a value and printing it in Java?

Printing with System.out.println displays text on the screen, while return passes a value back to the calling code. Only a returned value can be stored, compared, or used in later calculations.

Do you have to use a method's return value?

Java won't force you, but if you don't store it or use it in an expression, the value is thrown away. On the exam, ignoring the return value of a helper method is a common way to lose FRQ points.

How is a return value different from a return type?

The return type is the data type declared in the header, like double in public static double calculateArea(...). The return value is the actual result produced when the method runs, such as 12.0, and it must be of that type.