JAVA CODE
---------------
package Test; /** * Created by Akash on 7/5/2017. */class A { A() { System.out.println("Parent Constructor"); } static {System.out.println("Parent Static Initializer Block!");} public void methodA() { System.out.println("Parent method"); {System.out.println("Parent Initializer Block!");} } } public class TestTwo extends A { TestTwo() { super(); System.out.println("Child Constructor"); } static { System.out.println("Child Static Initializer Block!");} public static void main(String[] args) { TestTwo testTwo = new TestTwo(); testTwo.methodA(); System.out.println("Main before Initializer block"); {System.out.println("Child Initializer Block");} System.out.println("Main after Initializer block"); } }
OUTPUT
-----------
Child Static Initializer Block!
Parent Constructor
Child Constructor
Parent method
Parent Initializer Block!
Main before Initializer block
Child Initializer Block
Main after Initializer block