We will reserve the term extends to describe the immediate subclass (child) relation: A extends B iff A is an immediate subclass of B. Hence, the extends relation is neither transitive nor reflexive. Since Object is the top class of the hierarchy, all classes are subclasses of Object.
For example, the built-in classes Integer and Float extend the built-in class Number which extends Object. Hence, the superclass of Integer is Number, the superclass of Float is Number, and the superclass of Number is Object.
Object values are actually references to objects. For this reason, two different fields can be bound to exactly the same object. In Java, objects are never implicitly copied. When a field or method parameter v is bound to an object o, the value of v is a reference to the object o, not a copy of o! Scheme follows exactly the same conventions with regard to copying program data.
Every Java class C has an associated type C consisting of all instances of class C and all of its subclasses. Hence, the type Object contains all object values. The built-in class String has the class Object as its superclass. Since the class String has no subclasses, the only values of type String are instances of the class String. In contrast, the built-in class Number is a child of class Object and has several subclasses including Integer and Float. Hence, all instances of the classes Integer and Float are values of type Number.
In Java, every field and method has a declared type given as part of its definition. For a method, the declared type includes the type of the result and the types of the parameters. If a method does not return a value, then its declared return type is the degenerate type called void. There are no values of type void. A method with void return type does not return a value.
Java determines the type of every program expression using a simple set of rules and confirms that
We will discuss these ``type-checking'' rules in more detail in Section 1.12.2.