A computer is a machine that follows a list of instructions called a program. An Android device is a computer, and an app is a program. Inside the device are containers called variables that hold values such as numbers or pieces of text.

An object is a variable that is special in two ways. First, it can contain smaller variables inside it, called the fields of the object. Second, attached to an an object we can have lists of instructions—in effect, little programs—called methods.

There are many classes (types) of objects. Each object of a given class has the same set of fields and methods. For each class, we have to write a definition: a listing of the fields and methods that belong to each object of that class.

The code sample is a definition for a class named Car. Each Car object contains a field named mModel, holding the model number of that particular Car object. Each Car object also has two constructor methods, exactly one of which must be called (executed) when the Car is created. Each constructor puts a value into the mModel field of its newborn Car object, and also calls a method named setup to finish setting up the object.

The class definition specifies an access modifier for each field and method of its class. For example, the constructors of class Car are public: they can be called in the methods of another class of objects in the app. This makes it possible for objects of other classes to create objects of class Car. On the other hand, the mModel field is private: it can be mentioned only within the methods of the class to which it belongs. We say that a field has been encapsulated when its access modifier is private. The setup method is private too, because it is intended for use only by the other methods of this class.