欢迎来到天天文库
浏览记录
ID:58820621
大小:23.50 KB
页数:6页
时间:2020-10-25
《Java练习题(选择题).doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、选择题1选择题内容:下面各选项可以在A的子类中使用的是()classA{protectedintmethod(inta,intb){return0;}}选项A:A.publicintmethod(inta,intb){return0;}选项B:B.privateintmethod(inta,intb){return0;}选项C:C.privateintmethod(inta,longb){return0;}选项F:D.publicshortmethod(inta,intb){return0;}答案:AC选择题2选择题
2、内容:下列代码执行的结果是:classBase{voidtest(){System.out.println("Base.test()");}}publicclassChildextendsBase{voidtest(){System.out.println("Child.test()");}publicstaticvoidmain(String[]a){ChildanObj=newChild();BasebaseObj=anObj;baseObj.test();}}选项A:A.Child.test()Base.tes
3、t()选项B:B.Base.test()Child.test()选项C:C.Base.test()选项F:D.Child.test()答案:D选择题3选择题内容:关于以下程序代码的说明正确的是():1.classHasStatic{2.privatestaticintx=100;3.publicstaticvoidmain(Stringargs[]){4.HasStatichs1=newHasStatic();5.hs1.x++;6.HasStatichs2=newHasStatic();7.hs2.x++;8.hs
4、1=newHasStatic();9.hs1.x++;10.HasStatic.x--;11.System.out.println(“x=”+x);12.}13.}选项A:A.5行不能通过编译,因为引用了私有静态变量选项B:B.10行不能通过编译,因为x是私有静态变量选项C:C.程序通过编译,输出结果为:x=103选项F:D.程序通过编译,输出结果为:x=102答案:D选择题4选择题内容:关于java.lang.String类,以下描述正确的一项是()选项A:A.String类是final类故不可以继承;选项B:B.
5、String类是final类故可以继承;选项C:C.String类不是final类故不可以继承;选项F:D.String类不是final类故可以继承;答案:A选择题5选择题内容:下列关于interface的说法正确的是:()选项A:A.interface中可以有private方法选项B:B.interface中可以有final方法选项C:C.interface中可以有方法实现选项F:D.interface可以继承其他interface答案:D选择题6选择题内容:以下程序正确的输出是()publicclassFathe
6、rClass{publicFatherClass(){System.out.println("FatherClassCreate");}}publicclassChildClassextendsFatherClass{publicChildClass(){System.out.println("ChildClassCreate");}publicstaticvoidmain(String[]args){FatherClassfc=newFatherClass();ChildClasscc=newChildClass(
7、);}}选项A:A.FatherClassCreateFatherClassCreateChildClassCreate选项B:B.FatherClassCreateChildClassCreateFatherClassCreate选项C:C.ChildClassCreateChildClassCreateFatherClassCreate选项F:D.ChildClassCreateFatherClassCreateFatherClassCreate答案:A选择题7选择题内容:请看如下代码classPerson{pr
8、ivateinta;publicintchange(intm){returnm;}}publicclassTeacherextendsPerson{publicintb;publicstaticvoidmain(Stringarg[]){Personp=newPerson();Teachert=newTeacher();inti;//point
此文档下载收益归作者所有