java接口编程题(java面试编程题)

2023-11-13 08:25:29 数码极客 bianji01

 

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();

包名,类名保持一致,况且你的代码里面有中文,我给你把代码发过来吧

抽象和接口的java题目,多谢

java题目接口问题

声明:易趣百科所有作品(图文、音视频)均由用户自行上传分享,仅供网友学习交流。若您的权利被侵害,请联系315127732@qq.com
广告位招租
横幅广告