编程语言
810
interface Child3{ //private String uString; //不能出现变量 //private void f(); //不能出现私有成员方法 // String string; // private String string2; // private transient String string3; // private strictfp String string21; // public String string4; abstract void f(); void f1(); //protected void f2(); //不能出现保护成员方法 public void f3(); } class Child31 implements Child3{ public void f() { // 实现接口,不论接口里的是默认权限方法还是public方法, //都要写成public权限 // TODO Auto-generated method stub } public void f1() { // TODO Auto-generated method stub } public void f3() { // TODO Auto-generated method stub } } abstract class Child4{ String string; private String string2; //在抽象类里存在私有变量和私有方法的意思是什么? private transient String string3; // private strictfp String string21; //不能有strictfp修饰的成员变量 public String string4; public static String string5; // public final String string6; //不能有final修饰的成员变量 abstract void f2(); void f3(){} private void f4() {} protected void f5(){} public void f6(){} } class Child41 extends Child4{ @Override void f2() { //必须要实现的 抽象类里的抽象方法 // TODO Auto-generated method stub } void f3(){} //覆盖 除去不能覆盖抽象类的私有方法,其他权限都可以进行覆盖 // 且权限向下开放 protected void f5(){} //如:f5 可以保留protected权限,也可以public 但是不能是默认权限 public void f6(){} //如:f6 就只能最开放的public权限 public static void main(String[] args) { Child41 child41 = new Child41(); child41.f2(); child41.f3(); child41.f5(); child41.f6(); child41.f3(); System.out.println(child41.string+child41.string4); } }