Skip to content

Instantly share code, notes, and snippets.

@hpcx82
Created August 30, 2012 14:36
Show Gist options
  • Save hpcx82/3529765 to your computer and use it in GitHub Desktop.
Save hpcx82/3529765 to your computer and use it in GitHub Desktop.
Test the derived constructor, base constructor and initialization block calling sequence
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();
}
}
@hpcx82
Copy link
Author

hpcx82 commented Aug 30, 2012

output

D:\Source\Arena\java
$ java BaseConstructor
Base initialize block
Base()
Derived initialize block
Derived()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment