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, written in the language Java. 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. For example, a TextView object displays text on the screen, and might contain a field named mText. Second, attached to an an object we can have lists of instructions—in effect, little programs—called methods. Our TextView object might have a method named setText that puts a piece of text into the object’s mText field.

There are many classes (types) of objects. For each class, we have to write a definition: a listing of the fields and methods that belong to each object of the class. Each object of a given class has the same set of fields and methods. For example, every TextView object must have a field named mText and a method named setText. But it’s okay for each TextView to contain a different value in its mText field: one TextView might say "Hello" and another "Goodbye".

To define a class means to create the class by writing out its definition. We could then create objects of the class, but that’s a separate operation. It would be quite possible to define a class without creating any objects of the class.

We can define a new class from scratch, by listing every field and method that belongs to each object of the class. Or we can give the new class a head start, by saying that the new class automatically has all the fields and methods that belong to some existing class, plus the additional fields and methods listed in the definition of the new class. In this scenario, the existing class is called the superclass or base class, and the new class is its subclass. We say that the subclass inherits all the fields and methods of its superclass, and that the subclass was created from the superclass using inheritance. They’re called “sub” and “super” because in a diagram we always draw the subclass below the superclass. Note that a subclass usually has more methods and fields than its superclass.

Let’s take an example. An object of class EditText can do everything that an object of class TextView can do, plus more. It can display text on the screen, and also lets the user edit that text. Class EditText was therefore created from class TextView using inheritance, and has additional fields and methods to support editing.