Friday, March 4, 2011

Constructor chain execution with overriding methods inside

Note that when the Base constructor is called from within the Sub constructor, "this" clearly refers to an instance of Sub, not Base. Even though "this" has not been completely constructed yet, the JVM knows what class it will ultimately be. This is how it's able call overriding methods from the constructor.

No comments:

Post a Comment