范例现在编译无法通过,是JDK升级了吗?还是书本有错误。重写 protect Test2 标红

package com.javacongrumendaojingtong.chapter10;

class Test {

public  Test(){


}


protected  void   doSomething(){



}

protected  Test  dolt(){

   return  new  Test(); 

}

}

class Test2 extends Test{

    public  Test2(){

        super();

        super.doSomething();

    }

    public void  doSomethingnew(){



    }

    public  void doSometing(){


    }


    protected  Test2  dolt(){

        return  new  Test2();

    }

}

protected,重写出来还是protected,不能是public。按照OOP的观点(里氏替换原则),派生类不能改变基类的接口形式。