private 的属性和方法是不能被继承的。
能继承public,default,protected 的属性和方法。private只有对类本身才具有可见性,所以子类不能继承其方法和属性。

解决方案 »

  1.   

    JLS7 Page158
    A private class member or constructor is accessible only within the body of the top level
    class (§7.6) that encloses the declaration of the member or constructor. It is not inherited
    by subclasses.class A{
    private void x() {}
    }
    class B extends A{
    private int x() {
    return 0;
    }
    }由此可见私有成员不继承
      

  2.   

    Private 只能自己本身可见嘻嘻
      

  3.   

    父类中包含了privete的属性或者方法是父类私有的,对外界是不可见的。所以不能被继承!
      

  4.   

    private成员是不能被继承的,但是可以通过父类提供的公有方法进行使用。例如调用父类的构造对其进行赋值。故而实际上student是没有父类的private属性的字段的。
      

  5.   

    JLS都摆出来了,必须是正解!
      

  6.   

    就本例来讲 student类里面是null。一个类的私有方法不能继承。
      

  7.   

    以代码为证:public class Person {
    private String name = "lucy";
    private int age;

    public String getName() {
    return name;
    }
    public void setName(String name) {
    this.name = name;
    }
    }
    public class Student extends Person { public static void main(String[] args) 
    {
    Student s =new Student();
    System.out.println(s.getName()); }
    }
    结果是: lucy 
    说明是继承了,只是不能直接用.
      

  8.   

    继承就是继承父类全部的东西, 只是有些东西是受到保护的,
    保护程度就是用 private,public,protected 等标识来区分.