A class defines the variables and methods that objects of that class can have and do. An object is an instance of a class that has the data and behaviors defined by its class. A class can contain fields to store an object's data, methods to manipulate the object's data and status, and nested classes and interfaces. For example, the Pencil class defines string, int and float fields to store a pencil's color, length and diameter, and a method to set the pencil's color.