【Java学习】-inheritance

Inheritance doesn't just copy the interface of the base class. When you create an object of the derived class, it contains within it a subobject of the base class. This subobject is the same as if you had created an object of the base class by itself. It's just that from the outside, the subobject of the base class is wrapped within the derived-class object.

Default constructors don't have any arguments. It's easy for the comi;er to call these because there's no question about what arguments to pass. If your class doesn't have default arguments, or if you want to call a base-class constructor than has an argument, you must explicitly write the calls to the base-class constructor using the super keyword and the approciate argument list.

The call to the base-class constructor must be the first thing you do in the derived-class constructor.

上一篇:JS 中通过constructor 属性来查看对象是否为数组或者日期


下一篇:反射的基本