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. Android apps are 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 MediaPlayer object might contain fields holding the name of the sound file it is playing, the volume level, the current position of the playback in the file, and an indication of whether the file should be played in an infinite loop.
Second, attached to an an object we can have lists of instructions—in effect, little programs—called methods. For example, our MediaPlayer object might have methods named play, pause, and stop. The methods of an object can use the fields inside the object to which they are attached. For example, the play method would need to use all four of our fields. When we tell the device to execute a method, we say that we are calling the method.
There are many classes of objects, and objects of a given class have the same set of fields and methods. For example, every object of class MediaPlayer has the fields and methods discussed above. Meanwhile, an object of class TextView has a different set fields and methods, for displaying text on the screen.
Each class of object has a definition: a description that acts as a blueprint for the objects of the class. The definition of a class is written in the app and lists the fields that belong to each object of the class, specifying the name and data type of each field. It also lists the methods that belong to each object, specifying the name of each method and the list of instructions that constitute it. This method definition also specifies the names and data types of the method’s arguments and return value: the variables that hold the information that is passed to and from the method when it is called. When we write a method definition, we say that we are defining the method.