Java练习题(选择题).doc

Java练习题(选择题).doc

ID:58820621

大小:23.50 KB

页数:6页

时间:2020-10-25

Java练习题(选择题).doc_第1页
Java练习题(选择题).doc_第2页
Java练习题(选择题).doc_第3页
Java练习题(选择题).doc_第4页
Java练习题(选择题).doc_第5页
资源描述:

《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

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。