Introduction: Class Definitions—the Fundamentals

Here are the prerequisites, learning objectives, and overview for this chapter.

We'll cover the following

Prerequisites

Objectives

After completing this chapter, you should be able to

  • Use and implement constructors
  • Define data fields
  • Describe the use of the access modifiers public and private
  • Distinguish between formal parameters and arguments
  • Write a method definition
  • Describe the use of accessor methods and mutator methods, and write their definitions
  • Call a method, given its header
  • Describe the effect of a given call to a method
  • Write a class definition

Overview

The previous chapter discussed objects that belong to particular standard classes such as String and BigDecimal. We said that the data type of such objects is the name of their class. The objects have both data and behaviors that their class describes. The behaviors are the result of executing the methods defined by the class.

In this chapter, we will write our own classes and methods. By creating a class, we are in essence creating a new data type.

Get hands-on with 1200+ tech skills courses.