Created
August 30, 2012 14:36
-
-
Save hpcx82/3529765 to your computer and use it in GitHub Desktop.
Test the derived constructor, base constructor and initialization block calling sequence
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BaseConstructor | |
{ | |
static class Base | |
{ | |
{ | |
System.out.println("Base initialize block"); | |
} | |
Base() | |
{ | |
System.out.println("Base()"); | |
} | |
} | |
static class Derived extends Base | |
{ | |
{ | |
System.out.println("Derived initialize block"); | |
} | |
Derived() | |
{ | |
System.out.println("Derived()"); | |
} | |
} | |
public static void main(String[] args) | |
{ | |
Base b = new Derived(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
output
D:\Source\Arena\java
$ java BaseConstructor
Base initialize block
Base()
Derived initialize block
Derived()