Title: Key Concept - Method
Course: CPS 189: Java Certification - Review, Practice & Prepare (Development) > Section: Learning Modules

A method is a block of named code that is called as needed and executes until one of the following occurs:

- It completes all the statements in its block.
- It reaches a return statement.
- It throws an exception.

Upon completion, a method may or may not return a value.

- A method declared void does not return a value.
- A method declared with a data type must contain at least one return statement with a return value that matches that data type.

The data type may be:

- Primitive type – byte, short, int, long, float, double, boolean, or char.
- Reference type – class or interface.

For additional study, view resources under:

- Level 1 Study Materials: Unit 5