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