3.3. Create methods with arguments and return values

[6.1] Create methods with arguments and return values; including overloaded methods

In this section, you’ll work with the definitions of methods, which may or may not accept input parameters and may or may not return any values.

A method is a group of statements identified with a name. Methods are used to define the behavior of an object. A method can perform different operations, as shown in figure 3.13.

Figure 3.13. Different types of methods

  1. The method setModel can access and modify the state of a Phone instance.
  2. The method printVal uses only the method parameter passed ...

Get OCA Java SE 8 Programmer I Certification Guide now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.