1 class Father{
2 private int n = 100;
3 public int n2 = 200;
4
5 public void show() {
6 System.out.println(n);
7 System.out.println(n2);
8 }
9}
10 class Son extends Father {
11 public void function() {
12 System.out.println(n);
13 System.out.println(n2);
14 }
15 @Override
16 void show() {
17 System.out.println(n2);
18 }
19}
20 public class Test {
21 public static void main(String[] args) {
22 // 创建对象
23 Father f = new Son();
24 f.show();
25 f.function();
26 }
27 }
F 、 第23行 语句报错
G 、 第24行 访问不到show方法
H 、 第25行 父类中没有此方法,编译时期报错
|
|