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 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.