java模拟试卷与答案与解析4.docx

上传人:夺命阿水 文档编号:1463479 上传时间:2024-06-29 格式:DOCX 页数:11 大小:24.41KB
返回 下载 相关 举报
java模拟试卷与答案与解析4.docx_第1页
第1页 / 共11页
java模拟试卷与答案与解析4.docx_第2页
第2页 / 共11页
java模拟试卷与答案与解析4.docx_第3页
第3页 / 共11页
java模拟试卷与答案与解析4.docx_第4页
第4页 / 共11页
java模拟试卷与答案与解析4.docx_第5页
第5页 / 共11页
点击查看更多>>
资源描述

《java模拟试卷与答案与解析4.docx》由会员分享,可在线阅读,更多相关《java模拟试卷与答案与解析4.docx(11页珍藏版)》请在课桌文档上搜索。

1、复习题4一、选择题1 .在面向对象的方法中,一个对象请求另一个时象为其服务的方式是通过发送(D)A、调用语句B、命令C、1.J令D、消息2 .Java语言具有许多优点和特点,下列选项中,哪个反映了Java程序并行机制的特点:(B)A、安全性B,多线程C、蹿平台D,可移位3 .编写和运行JaVaaPPlet程序与编写和运行Javaapplication程序不同的步骗是:(B)A、编写源代码B.编写HTM1.文件调用该小程序,以html为扩展名存入相同文件夹C、编译过程D、解释执行4 .Java的字符类型采用的是Uni8de编码方案,每个Unicode码占用个比特位.(B)A、8B、16Cx32D

2、、645 .关于下列程序段的输出结果,说法正确的是:(D)publicclassMyClassstaticintI;publicstaticvoidmain(Strigarg0XSystem.out.println(i);)A、有错误,变量i没有初始化.B、nullC、1D.06 .卜列代码的执行结果是:(BpublicdassTest3(publicstaticvoidmai(Stringargs11)System.out.prit(100%3);System.out.prit();System.out.println(100%3.0);A、1,1B、1,1.0C、1.0,1D、1.0l1,

3、07 .下列程序段的输出结果是:(B)voidCOmPIiCatedeXPreSSionj)intx=20.y=30:booleanb;b=x50&y60|x50&y-60|x60|x-50&ySystem.out.println(first);)elseif(x3)Systm.outprintln(sendv);)else(System.OU1.PrintInCthird);请问x处于什么蔺围时将打印字符串“second?A,x0B、x-3C、x=-3D、x-39.若要把变量声名为暂时性变量,成使用如下哪种修饰符?(C)A,protectedB. provateC. transientD.

4、volatile10 .在JaVa中,一个类可同时定义许多同名的方法,这些方法的形式参数的个数、类型或顺序各不相同,传回的值也可以不相同,这种面向对望程序特性称为:(C)A、隐藏B、糙盖C、C/D、JaVa不支持此特性11 .如要抛出异常,应用下列哪种子句?(B)A、catchB、throwC、tryD、finally12 .在使用interface声明一个接口时,只可以使用修饰符修饰该接口。(D)A、privateB. protectedC. privateprotectedD.public13 .下列代码的输出结果是:(八)classParentvoidprintMe()System.ou

5、t.printl(parent);)classChildextendsParentvoidprintMe()System.out.println(child):)voidprintall()SuperprintMeO;this.p11ntMe();PrintMe();publicclassTestJhispublicstaticvoidmai(Stringargs11)ChildmyC=newChild();myC.printall();)A.parentchildchildB、parentChildparentC.parentchildD、D译错误14 .为读取的内容进行处理后再输出,需要使

6、用下列哪种流?(D)A、FilestreamB、PipestreamC. RandomstreamD. Filterstream15 .为实现多线程之间的通信,需要使用下列哪种流才合适?(D)A、FilterstreamB、FilestreamC、RandomaccessstreamD.Pipedstream16 .Swing与aWT的区别不包括:(D)A.Swing是由纯JaVa实现的轻员级构件B、Swing没有本地代码C、SWing不依赖操作系统的支持D、SWing支持图形用户界面17.在编写JaVaaPPlet程序时,若需要对发生事件作出响应和处理,一般需要在程序的开头写上语句。(C)A

7、、importjava.awt.*;B,importjava.alet.;C、importjava.io.*;D、importjava.awt.event,;18 .注释的基本原则不包括:(D)A、注驿应该熠加代码的清晰度B、注择要简洁C、在写代码之前写注释D、母报给每一条语句加注择19 .java.io包中定义了多个流类型来实现输入和输出功能,可以从不同的角度对其进行分类,按功能分为:(C)A、输入流和输出流B、字节流和字符流C、节点流和处理流20 .以下程序的运行结果为(B)publicclasslfTestpublicstaticvoidmai(Stringargs11intx=3;in

8、ty=1:if(x=y)System.out.println(Notequal);elseSystem.out.println(Equa);)A)NotequalBEqualC)无输出D)编译出错二.填空题1 .java.io包中的ObjeCtinPUtStream和ObjQOutputStream类主要用于对对象(Object)的读写.2 .在编写异常处理的JaVa程序中,每个catch语旬块都府该与v语句块对应,使得用该语句块来启动JaVa的异常处理机制。3 .顺序执行以下两个语句的输出结果是:_10_,Strings=我喜欢学习Java!:Systemout.PrintIn(Slengt

9、hO);4 .Java语言通过接口支持多.照_维承,使类继承具有更灵活的扩展性,5 .实例化对象:就是创建一个对象.5new运算衿来实现对纵的实例化。6 .我们用int来定义个整数,用Char来定义一个字符类型,称为原始数据类型,7 .当用户在TeXtFieId中输入一行文字后.按Wl车,实现Action1.istner-接I可实现时事件的响应。8 .包含SWing构件的APPlet(小应用程序)应该是_applet类的子类。三、写出下列程序的运行结果1 .下列程序的输出结果为:publicclassTestAppIeinti=0;Apple(inti)lhis.i=i;Appleincrea

10、ment(Xi+;returnthis;)voidprit()System.out.pritln(i=+i);)publicstaticvoidmain(StringOargs)Appleredapple=ewAppIe(100O);redappl.increament().increamnt().prit();)2 .结果为:i=10023 .卜列程序的输出结果为:classSuperClassprivateintn:SuprClass(XSyStem.oUlPrinUn(Superclass。):)SuperClass(int11System.out.pritln(SuerClass(+n

11、+);)classSubCIassextendsSuperClassprivateintn;SubClass(intn)super();System.out.println(SubClass(+n+),);this.n=n;)SubClass()super(300);System.out.println(SubClass();)publicclassTestSuperSubpublicstaticvoidmain(Stringargs)SubCIasssc=newSUbClaSS(400);2 .结果为:SuperCIassOSubClass(400)3 .下列程序的输出结果为:classFa

12、therClasspublicintvalue:publicvoidf()value=100;System.out.println(FatherClass.value=+value):)classChildCIassextendsFatherClasspublicintvalue;publicvoidf()suer.f();valu=200;System.out.println(ChildClassvalue=+value);System.out.println(value);System.out.println(super.value);)publicclassTestlnheritpubl

13、icstaticvoidmain(Stngargs)ChiIdCIasscc=newChildClass();cc.f();)3.输出结果是:FatherClass.value=100ChiIdCIassvalue=200200100四、程序设计1.编写一个“Student”类,该类拥有属性:校名、学号、性别、出生日期。方鹿修翳飕心嫡惴粽XeO.用斛EFMfRWO,还有其自己的阑性和方法:附加属性包括系department)、专业(major):方法包含设的系别和专业。(setDepartment(),setMajor()。1.classStudentStringname=湖南学院;intsN

14、um=888888;Stringsex=男;Stringbirth=198080;Stringsname;intScore;voidsetName(Stringa11sname=a;voidsetScore(intb11Score=b;)voidshow()System.OutprintInC所在学校:+name);SystemoutprintInC学号:+sNum);SystemoutprintInC性别:+se);SystemoutprintInC生日:+birth);System.out.pritln(姓名:+sname);System.out.println()成绩:+Score):c

15、lassUndergraduateextendsStudentStringdepartment;Stringmajor;voidsetDearment(Strigc)department=d)voidsetMajor(Stringd11major=d;)voidshow1()super.show();SystemoutprintInC系部:+department);System.out.println(专业:+major);)classStudentpublicstaticvoidmain(Stringarg11XStudentA=newStudent();UndergraduateB=new

16、Undergraduate();B.SelNamef许乳);B.setScore(95);B.setDeparmnt(信息工程系);B.setMajor(计机网络”);B.show1();)2.从键盘或者命令行输入3个数.求这三个数的最大猿.2.importjavax.swig.JOptionPane;publicclassMaxNumclassMyFrame3extendsFrame/privatePanelp;MyFrame3(int.inty,intw,inth,Colorc)super(FrameWithPane);set1.ayout(null);setBounds(x,y.w,h);SetBackground(C);Panelp=newPanel(null);p.setBounds(w4,h4,w2,h2);p.setBackground(Color.pink);add(p);setVisible(true);)

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 在线阅读 > 生活休闲


备案号:宁ICP备20000045号-1

经营许可证:宁B2-20210002

宁公网安备 64010402000986号