错题
1. 运行时的常量池
- 大小受方法区的影响
- 存放了编译时期产生的字面量
- 存放编译时期的符号引用
2. 向上转型
向上转型,父对象只要不是super调用,那么调用的方法一定是子类重写的方法。
/**
* @date 2020/9/11 7:02
* 向上转型
*/
public class Test08_Up {
public static void main(String[] args) {
Father3 father3 = new Son3();
father3.printOne();
father3.printTwo();
}
}
class Father3{
public void printOne(){ //(2)
System.out.println("A");
printTwo(); // 这里调用的子类的方法 (3)
}
public void printTwo(){ //(6)
System.out.println("B");
}
}
class Son3 extends Father3{
@Override
public void printOne() {
super.printOne(); //(1)
System.out.println("C");
}
@Override
public void printTwo() { // (4)
super.printTwo(); //(5)
System.out.println("D");
}
}