You are here


26 July, 2019 - 09:51
Available under Creative Commons-ShareAlike 4.0 International License. Download for free at

As stated earlier, the call to initialize() in the constructor of AFrame will only invoke the concrete initialize() method of the concrete descendant class of AFrame that is being instantiated. Because initialize() is polymorphic, care must taken to ensure proper initialization of descendant classes that are more than one level deep in the inheritance hierarchy of AFrame. Consider the following inheritance tree as illustrated by the following UML class diagram. Click here to see the code.

Figure 6.1 UML class diagram 

In overriding the initialize() method of FrameA, a direct subclass of AFrame, we should not invoke the initialize() method of the superclass AFrame via the call super.initialize() because super.initialize() is abstract. However, the initialize() method of any subclass of FrameA and below should make a call to the initialize() method of its direct superclass in order to ensure proper initialization.

For example, in the above diagram, new FrameAB("ab") calls the constructor FrameAB, which calls the constructor FrameA, which calls the constructor AFrame, which calls

  • the constructor JFrame and then calls
  • initialize(), which is the initialize() method of FrameAB which calls
    • super.initialize(), which should properly initialize FrameA, and then calls
    • the additional initialization code for FrameAB.


What is the chain of calls when we instantiate a FrameAC