The objects in your example use inheritance, which causes a chain of constructors to be called. When using inheritance a class inheriting from another (subtype
) must call the constructor of the class it extends (super type
). When a type hierarchy exists, meaning several classes extend from each other in a chain, the calls to the super constructor propagate to the first class in chain that does not inherit from another class (ignoring Object).
The super class constructors of a subtype must be called prior to the execution of the subtype's constructor since it may rely upon fields or methods in the super types. The constructor calls chain up the type hierarchy and once each constructor has initialized the subtype begins its instantiation.
Once the super type constructors in a classes type hierarchy have been called the fields of the subtype are declared since they may also be needed by the subtype's constructor. After the fields of the subtype are declared the subtype constructor executes.
This order is necessary because the subtype may rely upon fields or methods established in the super type.
Meal() (Top of Class Hierarchy, not including Object)
Lunch() (Extends Meal)
PortableLunch() (Extends Lunch)
Bread() (Field of lunch declared before constructor call)
Cheese() (Field of lunch declared before constructor call)
Lettuce() (Field of lunch declared before constructor call)
Sandwich() (Extends Portable Lunch)
Here is a really good overview of object creation in Java.