java 期末考试复习

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,别的几个关键字都不行
 

猜你喜欢

转载自www.cnblogs.com/immiao0319/p/10090591.html