Chapter 4. Classes and Objects

Java is an object-oriented programming language. To execute a Java program on the Java virtual machine, the JVM provides support for a number of basic object-oriented programming constructs. In this chapter we will explore that part of the JVM instruction set that facilitates an object-oriented programming style.

What Is an Object?

An object is an entity with four properties:

  • It has an identity. An object is not the same object as any other object.

  • It has a class. Each object is a member of exactly one class.

  • It may have fields. A field is a slot for storing values. All objects of the same class have the same fields. When you alter the fields of an object, it does not affect any other object.

  • It may have methods invoked ...

Get Programming for the Java™ Virtual Machine now with O’Reilly online learning.

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