Summary

Section 3.2 Classes, Objects, Methods and Instance Variables

  • Performing a task in a program requires a method. Inside the method you put the mechanisms that make the method do its tasks—that is, the method hides the implementation details of the tasks that it performs.

  • The program unit that houses a method is called a class. A class may contain one or more methods that are designed to perform the class’s tasks.

  • A method can perform a task and return a result.

  • A class can be used to create an instance of the class called an object. This is one of the reasons Java is known as an object-oriented programming language.

  • Each message sent to an object is known as a method call and tells a method of the object to perform its task.

  • Each method can ...

Get Java™ How to Program, Seventh Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.