Fiveable
Fiveable

Return Type

Definition

The return type in programming refers to the data type of the value that a method or function will return when it is called. It specifies what kind of data will be returned by the method.

Analogy

Think of a vending machine. When you insert money and press a button, you expect to receive something in return. The return type is like the label on the vending machine that tells you what kind of item you can expect to get back.

Related terms

Method Name: The name given to a method or function which helps identify and call it within a program.

Parameters: Inputs or arguments passed into a method or function for it to perform its task.

Data Type: Specifies the type of data that can be stored in a variable, such as integer, string, boolean, etc.

"Return Type" appears in:

Practice Questions (9)

  • Which of the following is true regarding the return type of an overriding method in a subclass?
  • When a subclass defines a method with the same name, return type, and parameters as a method in its superclass, it is an example of:
  • What happens if a method is declared with a return type but does not contain a return statement?
  • Can a constructor have a return type in Java?
  • What should the return type of a getter method that retrieves a variable storing the number of siblings a person has be?
  • The return type of a getter method is...
  • What should the return type of a getter method that gives us the value of a variable storing the school a person attends be?
  • What should the return type of a getter method that returns the value of a variable storing whether or not a person is above 5 foot 2 be?
  • What is the purpose of a return type in a method header?


© 2024 Fiveable Inc. All rights reserved.

AP® and SAT® are trademarks registered by the College Board, which is not affiliated with, and does not endorse this website.


© 2024 Fiveable Inc. All rights reserved.

AP® and SAT® are trademarks registered by the College Board, which is not affiliated with, and does not endorse this website.