7 Introduction to Classes and Objects

Objectives

In this chapter you’ll:

  • Declare a class and use it to create an object.

  • Implement a class’s behaviors as methods.

  • Implement a class’s attributes as instance variables.

  • Call an object’s methods to make them perform their tasks.

  • Learn how local variables of a method differ from instance variables of a class.

  • Learn what primitive types and reference types are.

  • Use a constructor to initialize an object’s data.

  • Learn why classes are a natural way to model real-world things and abstract entities.

Get Java How To Program, Late Objects, 11th 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.