




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、java程序设计课程 试卷1一、单选题(每题1分,共12分)1.给定下面的代码片段: 1) string str = null; 2) if (str != null) && (str.length() > 10) 3) system.out.println("more than 10"); 4) 5) else if (str != null) & (str.length() < 5) 6) system.out.println("less than 5"); 7) 8) else system.out.printl
2、n("end"); 哪些行会导致错误?a、 line 1 b、 line 2 c、 line 5 d、 line 8 2.下面哪种注释方法能够支持javadoc命令: a、 /*.*/ b、 /*.*/ c、 / d、 /*.*/ 3.欲编写如下图的一个界面,用于显示用户指定的图像: 如果在区域a中只能放置一个awt组件,从各组件的本来功能角度考虑,最好使用哪种组件:a、 textarea b、 panel c、 applet d、 canvas 4.界面如上题所示。若"button1"的功能是:点击后弹出一个用于输入的界面,获取用户想要显示的图像文件名
3、,则该界面最好是a、 模式(modal)dialog b、 非模式(none-modal)dialog c、 filedialog d、 frame 5.界面如上题所示。如果在a区域使用某种awt组件(java.awt.component的子类)来负责绘制图像,则绘图的语句最好应放在该组件的哪个方法中(考虑到应用程序和java虚拟机的awt线程都会要求重画该组件)? a、 构造方法 b、 paint(graphics g) c、 update(graphics g) d、 repaint() 6.下面关于applet的说法正确的是a、 applet也需要main方法 b、 applet必须继承
4、自java.awt.applet c、 applet能访问本地文件 d、 applet程序不需要编译 7.看下面一段程序: class aclass void go() system.out.println("aclass"); public class bclass extends aclass void go system.out.println("bclass"); public static void main(string args) aclass a=new aclass(); aclass a1=new bclass(); a.go();
5、a1.go(); 以上程序运行结果是:a、 aclass aclass b、 bclass bclass c、 aclass bclass d、 bclass aclass 8.下列关于java线程的说法那些是正确的a、 每一个java线程可以看成由代码、一个真实的cpu以及数据三部份组成。 b、 创建线程的两种方法中,从thread类中继承的创建方式可以防止出现多父类问题。 c、 thread类属于java.util程序包。 d、 以上说法无一正确。 9.看以下程序: boolean a=false; boolean b=true; boolean c=(a&&b)&
6、&(!b); int result=c=false?1:2; 这段程序执行完后,c与result的值是:a、 c=false;result=1; b、 c=true;result=2; c、 c=true;result=1; d、 c=false;result=2; 10.运行下列程序, 会产生什么结果public class x extends thread implements runable public void run() system.out.println("this is run()"); public static void main(string
7、 args) thread t=newthread(new x(); t.start(); a、 in the inner outer b、 outer c、 in the inner d、编译不通过 11.指出下列程序的运行结果int i = 9; switch (i) default: system.out.println("default"); case 0: system.out.println("zero"); break; case 1: system.out.println("one"); case 2: system.
8、out.println("two"); a、 default b、 default, zero c、 error default clause not defined d、 no output displayed那个 12.运行下列程序,会产生什么结果:class outer1 private int a; void foo(double d,final float f) string s; final boolean b; class inner void methodinner() system.out.println("in the inner")
9、; public static void main(string args) outer1 me=new outer1(); me.foo(123,123); system.out.println("outer"); a、 in the inner outer b、 outer c、 in the inner d、 编译不通过 二、多项选择题(每题2分,共22分)1.下面哪些标识符在java语言中是合法的?a、 persons$ b、 twousers c、 *point d、 instanceof f.end-line 2.下面哪些代码片段会产生编译错误?a、 strin
10、g s = "gone with the wind" string t = " good " string k = s + t; b、 string s = "gone with the wind" string t; t = s3 + "one" c、 string s = "gone with the wind" string standard = s.touppercase(); d、 string s = "home directory" string t = s -
11、 "directory". 3.下面哪些赋值语句是错误的?a、 float f = 11.1; b、 double d = 5.3e12; c、 char c = 'r' d、 byte bb = 433; e、 boolean b=true; 4.给定下面的代码片段: public void test() try method(); system.out.println("hello world"); catch (arrayindexoutofboundsexception e) system.out.println("ex
12、ception?"); catch(exception e) system.out.println("exception1"); finallysystem.out.println("thank you!"); 如果函数method正常运行并返回,会显示下面的哪些信息?a、 hello world b、 exception c、 exception1 d、 thank you! 5.下列哪些语句是正确的? a、 int a=new int3; b、 int a=1,3,2,3,4,1,2; c、 string s=new string2; d、
13、 string s="can","i","help","you" 6.下面哪些语句能够正确地生成5个空字符串?a、 string a = new string 5; for (int i = 0; i < 5; ai+ = ""); b、 string a = "", "", "", "", "" c、 string a 5; d、 string 5 a; e、 string a = new
14、 string 5; for (int i = 0; i < 5; ai+ = null); 7.下面关于java代码安全的说法哪些是正确的?a、 程序执行过程中需要的所有类都是通过字节码校验程序装入的。 b、 代码的运行是由java运行环境中的解释器完成的。 c、 在运行时,字节码要经过装入,校验之后,才能在解释器中执行。 d、 在缺省的安全配置条件下,java applet不能访问任何本地资源。 8.下列方法属于java.lang.math类的有(方法名相同即可):a、 random() b、 abs() c、 sqrt() d、 sin() 9.下列表达式哪些是正确的:a、 byt
15、e=340; b、 boolean=1; c、 long l=-2; d、 double=0.9239d; 10.下面的说法正确的是:a、 java语言里的线程不是对象 b、 applet不需要main方法 c、 java语言的对象都是java.lang.object的子类 d、 double是java语言的合法标识符 11.下面的java语句错误的是:a、 double a=1.0; b、 double a=1.0; c、 out.println("hello"); d、 datagramsocket a = new datagramsocket() 三、 填空题(每空2
16、分,共18分)1.java中类成员的限定词有以下几种:private, public, _, _。其中,_的限定的范围最大。2.java中所有类都是类_的子类。3.请填出在java.lang包中与下列基本数据类型相对应的封装类: float:java.lang.float, char:_, boolean:_。 4.请写出下面程序的运行结果。 public class test extends tt public void main(string args) test t = new test("tom"); public test(string s) super(s);
17、system.out.println("how do you do?"); public test() this("i am tom"); class tt public tt() system.out.println("what a pleasure!"); public tt(string s) this(); system.out.println("i am "+s); 结果:5.给定下面的未完成的代码片断: public class example int x,y; public example(int a
18、) x = a; public example(int a, int b) /和上面一个参数的构造方法做同样的操作,包括赋值x=a y = b; 如果要用最简捷的一行代码实现"/和上面一个参数的"注释所指出的功能,请写出你认为最合适的一行代码:6.如果有一个类myframe是frame的子类,能够被不同包中的类所使用,同时又能够为线程提供运行代码(run()方法),请写出该类的声明头。 你的解答:四、 编程题(每题10分,共40分)1.编写一个程序用选择法对数组a=20,10,50,40,30,70,60,80,90,100进行由大到小的排序。2.使用socket编写一个服务器端程序,服务器端程序在端口8888监听,如果它接到客户端发
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 幼儿园教研学期工作计划的科学素养与实验教育
- 全媒体运营中的用户画像构建试题及答案
- 完善产品上市计划的工作安排
- 充分利用每月时间的方法计划
- 推动项目式学习的实施路径计划
- 深入研究人力资源管理师试题及答案
- 监理工作实际案例试题及答案
- 天然气与地理环境关系试题及答案
- 家庭教育指导师精粹试题及答案总结
- 2024育婴师试题及答案在线学习
- 牧原应聘笔试试题及答案
- 2025年新版供电营业规则考试题库
- 【初中语文】第11课《山地回忆》课件+2024-2025学年统编版语文七年级下册
- 华为创业成功案例分析
- 2025年事业编畜牧笔试试题及答案
- 排水工程监理细则
- 新教科版一年级科学下册第一单元第6课《哪个流动得快》课件
- 2025年新人教PEP版英语三年级下册全册课时练习
- 平面块料拆除施工方案完整
- 寿命测试记录表格
- 18号道岔专项施工方案
评论
0/150
提交评论