inheritance
? Constructors are inherited, but use super()
public class Parent { public Parent() { do some code; } } public class Child extends Parent { public Child() { super(); // call Parent() do some more code; } } so in a main method: Child c = new Child(); // Calls Parent(), too
Default constructor == no parameters
第72页,子类能加新方法吗?
只有public方法的可以override,别的几个关键字都不行
原文地址:https://www.cnblogs.com/immiao0319/p/10090591.html
时间: 2024-10-11 03:45:44