See program Write results:A: A static block of code for a class, constructing a block of code, and implementing a process for constructing a methodstatic code blocks > Constructing code blocks > Construction MethodsB: Static content is loaded as the class loadsthe contents of a static block of code take precedenceC: The initialization of the parent class before the subclass is initialized The result is:Static code block FUstatic code block Ziconstruct code block FUConstruction Method FuConstructing code blocks ziConstruction Method Zi
class Fu {Static {System.out.println ("Static code block Fu"); } {System.out.println ("Construct code block Fu"); } Public Fu () {System.out.println ("Construction Method Fu"); }} class Zi extends Fu {Static {System.out.println ("Static code block Zi"); } {System.out.println ("Construct code block Zi"); } Public Zi () {System.out.println ("Construction Method Zi"); }} class ExtendsTest2 {Public static void Main (string[] args) {Zi z = new Zi (); }}
|
Java Inheritance Exercises