8.4 本章练习

1 下面代码的输出结果为________。

public class Sub extends Super{   

​    public int i = 100 ;  

​    public static void main(String[] args) {  

​        Super sup = new Sub();

​        Sub sub = new Sub();

​        System.out.println((sup.i + sub.i));   

​    }   

} 

class Super {   

​    public int i = 50 ; //父类属性i,赋值50  

}
copy

2 请描述类抽象的步骤。

3 String类可以被继承吗?为什么?

4 请介绍重载和重写的区别。

5 什么是多态,请使用一个例子进行说明。