Here is some info to round out the inheritance topics we've been discussing.
| Access Modifiers | |
| |
A child class method or variable can be made more public than the one it
is overriding/shadowing, but not less public.
|
Binding and this |
|
| Although never declared anywhere, this is just another variable
referencing an object. The reference type of this matches the
type of the class the currently-executing code is located inside. But
like any other variable, the actual object pointed to by this may
instead be a subtype of that reference type. So static and dynamic
binding based on this CAN give different results. For example: class P { f() {...} } class C extends P { ... } C obj = new C(); obj.f(); While in f(), this is of type P but it points to an object of type C. |
|
| Constructors & Initializers | |
Starting at the constructor that is actually invoked with new,
things happen in this order:
|
|