java关于接口的编程题
class?Main?{public?static?void?main(String[]?args)?{IPerson?person?=?new?Person();person.setFood("西红柿炒鸡蛋");person.eat();interface?IPerson{void?eat();void?setFood(String?food);class?Person?implements?IPerson{private?String?food;@Overridepublic?void?eat()?{System.out.println("正在吃"?+?food);@Overridepublic?void?setFood(String?food)?{this.food?=?food;接口的编程题
JAVA编程题,难,求解答,在线等
packagecom.test.demo;
publicinterfaceIUSBStorage{
publicvoidreadMe();
publicvoidwriteMe();
packagecom.test.demo;
publicclassCellPhoneimplementsIUSBStorage{
publicStringhostNumber;//本机号
publicvoidcall(Stringnumber){
publicvoidtakePicture(){
@Override
publicvoidreadMe(){
//TODOAuto-generatedmethodstub
@Override
publicvoidwriteMe(){
//TODOAuto-generatedmethodstub
packagecom.test.demo;
publicclassUDiskimplementsIUSBStorage{
@Override
publicvoidreadMe(){
//TODOAuto-generatedmethodstub
@Override
publicvoidwriteMe(){
//TODOAuto-generatedmethodstub
packagecom.test.demo;
publicclassComputer{
publicstaticvoidmain(String[]args){
IUSBStorageud=newUDisk();
ud.readMe();
IUSBStoragecp=newCellPhone();
cp.readMe();
cp.writeMe();
包名,类名保持一致,况且你的代码里面有中文,我给你把代码发过来吧