JAVA期末考试试卷及答案.pdf
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_05.gif)
《JAVA期末考试试卷及答案.pdf》由会员分享,可在线阅读,更多相关《JAVA期末考试试卷及答案.pdf(8页珍藏版)》请在得力文库 - 分享文档赚钱的网站上搜索。
1、二选择题;选择题;1以下哪个方法用于定义线程的执行体?(C)A、start()B、init()C、run()D、synchronized()2下面哪个不是 Java 中的容器?(B)A、ScrollPaneB、CanvasC、AppletD、Dialog3下面哪个方法与 applet 的显示无关?(A)A、draw()B、update()C、repaint()D、paint()4当 Frame 改变大小时,放在其中的按钮大小不变,则使用如下哪种布局方式?(A)A、FlowLayout B、CardLayout C、BorderLayoutD、GridLayout5有如下代码段:1)2)if(u
2、nsafe()/do something3)else if(safe()/do the other4)其中,方法 unsafe()将抛出 IOException,请问可将以下哪项填入第1 行?(D)A、public IOException methodName()B、public void methodName()C、public void methodName()throw IOExceptionD、public void methodName()throws IOException6以下哪个关键字可以用来对对象加互斥锁?(B)A、transientB、synchronizedC、seria
3、lizeD、static7在使用 interface 声明一个接口时,只可以使用(D)修饰符修饰该接口。A、privateB、protectedC、privateprotectedD、public8编译并运行以下程序,以下描述哪个选项是正确的(C)1.classA 2.protectedbooleanequals()3.returnsuper.equals();4.A、编译通过运行无异常B、编译通过但运行时出错C、行 2 出错,不能成功编译D、不能成功编译,行3 出错9Java 的字符类型采用的是 Unicode 编码方案,每个 Unicode 码占用(B)个比特位。A、8B、16C、32D、
4、6410 在编写 JavaApplet 程序时,若需要对发生的事件作出响应和处理,一般需要在程序的开头写上(语句。A、importjava.awt.*;B、importjava.applet.*;C、importjava.io.*;D、importjava.awt.event.*;11以下关于构造函数的描述错误的是(A)。A、构造函数的返回类型只能是void 型。B、构造函数是类的一种特殊函数,它的方法名必须与类名相同。C、构造函数的主要作用是完成对类的对象的初始化工作。D、一般在创建新对象时,系统会自动调用构造函数。第 1 页 共 8 页D)12有程序如下,关于程序的描述哪个是正确的?(C)
5、public class Personstatic int arr=new int10;public static void main(String a)System.out.println(arr1);A、编译将产生错误B、编译时正确,但运行时将产生错误C、正确,输出 0D、正确,输出 null13有语句 String s=”hello world”;,以下操作哪个是不合法的?(B)A、int i=s.length();B、s=3;C、String ts=s.trim();D、String t=s+”!”;14给出如下代码:class Testprivate int m;public sta
6、tic void fun()/some code.如何使成员变量 m 被函数 fun()直接访问?(C)A、将 private int m改为 protected int mB、将 private int m改为 public int mC、将 private int m改为 static int mD、将 private int m改为 int m15 Java application 中的主类需包含 main 方法,main 方法的返回类型是什么?(D)A、intB、floatC、doubleD、void16有以下方法的定义,请选择该方法的返回类型(D)。ReturnTypemethod(
7、byte x,double y)return(short)x/y*2;A、byteB、shortC、intD、double17下列哪些语句关于Java 内存回收的说明是正确的?(B)A、程序员必须创建一个线程来释放内存B、内存回收程序负责释放无用内存C、内存回收程序允许程序员直接释放内存D、内存回收程序可以在指定的时间释放内存对象18 在编写 JavaApplet 程序时,若需要对发生的事件作出响应和处理,一般需要在程序的开头写上(语句。A、importjava.awt.*;B、importjava.applet.*;C、importjava.io.*;D、importjava.awt.eve
8、nt.*;19容器 Panel 和 Applet 缺省使用的布局编辑策略是(B)A、BorderLayoutB、FlowLayoutC、GridLayoutD、CardLayout20设有下面两个赋值语句:a=Integer.parseInt(“123”);b=Integer.valueOf(“123”).intValue();下述说法正确的是(D)。A、a 是整数类型变量,b 是整数类对象。B、a 是整数类对象,b 是整数类型变量。第 2 页 共 8 页D)C、a 和 b 都是整数类对象并且值相等。D、a 和 b 都是整数类型变量并且值相等。21编译并运行以下程序,以下描述哪个选项是正确的(
9、C)。1.classA2.protectedStringtoString()3.returnsuper.toString();4.A、编译通过运行无异常C、行 2 出错,不能成功编译1.2.publicclassInteresting3./do sth4.B、编译通过但运行时出错D、不能成功编译,行3 出错22有以下程序片段,下列哪个选项不能插入到行1。(D)A、import java.awt.*;C、class OtherClassA、TRUEB、constB、package mypackage;D、public class MyClass C、superD、void23以下哪个不是 Jav
10、a 的关键字?(A)24关于以下 application 的说明,正确的是(C)。1classStaticStuff2 3staticintx;4static x+=5;5publicstaticvoidmain(Stringargs)67System.out.println(“x=”+x);89static x/=5;10A、4 行与 9 行不能通过编译,因为缺少方法名和返回类型B、9 行不能通过编译,因为只能有一个静态初始化器C、编译通过,执行结果为:x=1D、能通过编译,但程序运行结果不可预知,因为变量x 没有初始化25FilterOutputStream是 BufferedOutput
11、Stream、DataOutputStream及 PrintStream 的父类,以下哪个类可能是FilterOutputStream构造函数的参数类型?(BA、OutputStreamA、privateB、FileB、protectedC、InputStreamD、BufferedOutputStream26在使用 interface 声明一个接口时,只可以使用(D)修饰符修饰该接口。C、privateprotectedD、public27有程序片段如下,以下哪个表示式的结果为true?(B)Floats=newFloat(0.1f);Floatt=newFloat(0.1f);Double
12、u=newDouble(0.1);A、s=tB、s.equals(t)C、u.equals(s)D、t.equals(u)三程序阅读题程序阅读题1写出以下程序的运行结果。(54321)(54321)publicclassTestArraypublicstaticvoidmain(Stringargs)inti,j;第 3 页 共 8 页inta =1,3,2,5,4;for(i=0;i a.length-1;i+)intk=i;for(j=i;j ak)k=j;inttemp=ai;ai=ak;ak=temp;for(i=0;ia.length;i+)System.out.print(ai+)
13、;System.out.println();2写出以下程序的功能。(在屏幕上输出在屏幕上输出 test.javatest.java 文件的内容文件的内容)import java.io.*;classFileIODemopublic static void main(String args)throws IOExceptionint b;FileInputStreamfileIn=new FileInputStream(“test.java”);while(b=fileIn.read()!=-1)System.out.print(char)b);3 3写出以下程序的运行结果。Str0str1st
14、r2Str0str1str2str0str2str0str2import java.util.*;public classVecpublic static void main(String args)Strings;s=new String2;s0=new String(str1);s1=new String(str2);Vectorv=new Vector();for(int i=0;i 2;i+)v.addElement(si);v.insertElementAt(new String(str0),0);Enumeration e=v.elements();while(e.hasMoreE
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- JAVA 期末考试 试卷 答案
![提示](https://www.deliwenku.com/images/bang_tan.gif)
限制150内