欢迎来到天天文库
浏览记录
ID:51259121
大小:42.00 KB
页数:8页
时间:2020-03-20
《java试题库程序分析题挑选好最终.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、难度级别:3知识点:继承(5-4)试题内容:classArt{Art(){System.out.println("Artconstructor");}}classDrawingextendsArt{Drawing(){super();System.out.println("Drawingconstructor");}}publicclassCartoonextendsDrawing{Cartoon(){super();System.out.println("Cartoonconstructor");
2、}publicstaticvoidmain(String[]args){Cartoonx=newCartoon();}}难度级别:3知识点:继承(5-4)试题内容:classGame{Game(inti){System.out.println("Gameconstructor");}}classBoardGameextendsGame{BoardGame(inti){super(i);System.out.println("BoardGameconstructor");}}publicclassCh
3、essextendsBoardGame{Chess(){super(11);System.out.println("Chessconstructor");}publicstaticvoidmain(String[]args){Chessx=newChess();}}难度级别:3知识点:继承(5-4)试题内容:classVehicle{publicvoiddrive(){System.out.println("Vehicle:drive");}}classCarextendsVehicle{publi
4、cvoiddrive(){System.out.println("Car:drive");}}publicclassTest{publicstaticvoidmain(Stringargs[]){Vehiclev=newVehicle();Carc=newCar();v.drive();c.drive();v=c;v.drive();}}难度级别:3知识点:构造函数的重载(5-3)试题内容:写出下面程序的输出结果classC0{publicC0(intx){System.out.println("C
5、0"+x);}C0(){System.out.println("C0");}}classC1extendsC0{publicC1(intx){System.out.println("C1"+x);}publicstaticvoidmain(Stringargs[]){newC1(1);}}难度级别:3知识点:构造函数的重载(5-3)3、试题内容:写出下面程序的输出结果classParent{Parent(){System.out.println("调用父类的parent()构造方法");}}clas
6、sSubParentextendsParent{SubParent(){System.out.println("调用子类的SubParent()构造方法");}}publicclassSubroutineextendsSubParent{Subroutine(){System.out.println("调用子类的Subroutine()构造方法");}publicstaticvoidmain(String[]args){Subroutines=newSubroutine();}}难度级别:3知识点:
7、构造函数的重载(5-3)试题内容:classTest{publicstaticintMAX=100;Test(){System.out.println("调用无参构造方法");}Test(inti){System.out.println("调用有参构造方法");}publicintf(inta){returna+Test.MAX;}publicintf(inta,intb){returna+b;}}publicclassTestDemo{publicstaticvoidmain(Stringargs
8、[]){System.out.println(Test.MAX);Testt1=newTest();System.out.println(t1.f(10,20));Testt2=newTest(10);System.out.println(t2.f(10));}}难度级别:3知识点:构造函数(4-1)试题内容:查看下列程序并指出其输出结果。classA{publicA(){System.out.println("Aiscalled");}}classBextendsA
此文档下载收益归作者所有