The Object class is the top class in the hierarchy and serves as the default superclass for program-defined classes. 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 .
Object values are actually references to objects.
For this reason, two different fields can be bound to exactly the same object. 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. In the Hello class above, the main method has result type void , which is empty. In Java, there are no values of type void .