- class Fu
- {
- private int num = 3;
- public void setNum(int num)
- {
- this.num = num;
- }
- public int getNum()
- {
- return this.num;
- }
- }
- class Zi extends Fu
- {
- private int num = 5;
-
- public void show()
- {
- int num = 6;
- System.out.println("num="+this.num);
- super.setNum(10);
- System.out.println("num="+super.getNum());
- }
- }
- class ExtendsDemo2
- {
- public static void main(String[] args)
- {
- Zi z = new Zi();
- z.show();
- }
- }
复制代码 问题:父类成员为private的成员num,子类继承到了吗?我理解的是子类继承到了,但是因为私有不能直接访问,是这个意思吗?
|