Java接口练习中问题

1、

public interface Utility { private int Max_SIZE = 20; int MIN_SIZE=10; void use(){ System.out.println(\); } private int getSize(); }

1、

Illegal modifier for the interface field Utility.Max_SIZE; only public, static & final are permitted

Illegal modifier for the interface method getSize; only public & abstract are permitted Abstract methods do not specify a body

2、 3、

三个错误的简记

2、

package cn.bdqn.execise; public interface Utility { }

package cn.bdqn.execise;

class FourWheeler implements Utility{} class Car extends FourWheeler{} class Bus extends FourWheeler{}

public class Test { public static void main(String[] args) { Utility car=new Car(); FourWheeler bus=new Bus(); Utility ut =new Utility(); Bus bus=new FourWheeler(); } }

黄色部分是显然错误的。 绿色部分是正确的。 但绿色的第一句很独特。

联系客服:779662525#qq.com(#替换为@) 苏ICP备20003344号-4