3. Introduction to Classes and Objects

Objectives

In this chapter you’ll learn:

• What classes, objects, methods and instance variables are.

• How to declare a class and use it to create an object.

• How to declare methods in a class to implement the class’s behaviors.

• How to declare instance variables in a class to implement the class’s attributes.

• How to call an object’s methods to make those methods perform their tasks.

• The differences between instance variables of a class and local variables of a method.

• How to use a constructor to ensure that an object’s data is initialized when the object is created.

• The differences between primitive and reference types.

You will see something new. Two things. And I call them Thing One and ...

Get Java™ for Programmers: Deitel now with O’Reilly online learning.

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