2005年4月全国计算机等级考试二级JAVA笔试试题及答案
来源:优易学  2010-1-15 9:41:59   【优易学:中国教育考试门户网】   资料下载   IT书店

 

(31)当浏览器重新返回Applet所在页面时,将调用Applet类的方法是 
A.start() 
B.init() 
C.stop() 
D.destroy() 
答案:A 

(32)按照Java的标识符命名规范,下列表示一个类的标识符正确的是 
A.Helloworld 
B.HelloWorld 
C.helloworld 
D.helloWorld 
答案:B 

(33)下列代码中,将引起一个编译错误的行是 
1)public class Test{ 
2) int m,n; 
3) public Test() {} 
4) public Test(int a) {m=a;} 
5) public static void main(String args[]){ 
6) Test t1,t2; 
7) int j,k; 
8) j=0;k=0; 
9) t1=new Test(); 
10) t2=new Test(j,k); 
11) } 
12)} 
A.第3行 
B.第5行 
C.第6行 
D.第10行 
答案:D 

(34)下列程序的功能是在监控台上每隔一秒钟显示一个字符串“Hello”,能够填写在程序中下划线位
置,使程序完整并能正确运行的语句是 
public class Test implements Runnable{ 
public static void main(String args[]){ 
Test t=new Test(); 
Thread tt=new Thread(t); 
tt.start(); 

public void run(){ 
for(;;){ 
try{ 

}catch( e){} 
System.put.println("Hello"); 



A. sleep(1000) 
InterruptedException 
B. sleep(1000) 
InterruptedException 
C. Thread.sleep(1000) 
RuntimeException 
D. Thread.sleep(1000) 
InterruptedException 
答案:D 

(35)阅读下列代码后 
public class Person{ 
int arr[]=new int[10]; 
public static void main(String args[]){ 
System.out.println(arr[1]); 


正确的说法是 
A. 编译时将产生错误 
B. 编译时正确,运行时将产生错误 
C. 输出零 
D. 输出空 
答案:A 

二、填空题(每空2分,共40分) 
请将每空的正确答案写在【1】至【20】序号的横线上,答在试卷上不得分。
 
(1)某二叉树中度为2的结点有18个,则该二叉树中有 【1】   个叶子结点。  答案:19 
(2)在面向对象方法中,类的实例称为 【2】    。  答案:对象 
(3)诊断和改正程序中错误的工作通常称为 【3】    。  答案:调试或程序调试或软件调试或Debug(英文字母大小写均可)或调试程序或调试软件 
(4)在关系数据库中,把数据表示成二维表,每一个二维表称为 【4】    。  答案:关系或关系表
(5)问题处理方案的正确而完整的描述称为 【5】    。  答案:算法或程序或流程图 
(6)面向对象的语言将客观世界都看成由各种对象组成,共同特征和行为的对象组成类,类是变量和 【6】    的集合体。  答案:方法 
(7)Java源文件中最多只能有一个 【7】    类,其它类的个数不限。  答案:public 
(8)在Java中所实现的多维数组,实际上是由一维数组构成的 【8】    。  答案:数组的数组 
(9)StringBuffer类提供 【9】    字符串对象的表示。  答案:可变或可编辑 
(10)每个Applet程序必须有一个类是 【10】    类的子类。  答案:Applet 
(11)线程在生命期中要经历5种状态,分别是新建状态、可运行状态、运行状态、 【11】    状态和终止状态。  答案:阻塞 
(12)FileInputStream是字节流;BufferedWriter是字符流;ObjectOutputStream是 【12】    。  答案:对象流或对象输出流 
(13)break语句最常见的用法是在switch语句中,通过break语句退出switch语句,使程序从整个switch 语句后面的 【13】    开始执行。  答案:第一条语句 
(14)请阅读下列程序代码,然后将程序的执行结果补充完整。 
public class throwsException { 
static void Proc(int sel) 
throws ArithmeticException,ArrayIndexOutOfBoundsException{ 
System.out.println("In Situation"+sel); 
if(sel==0){ 
System.out.println("no Exception caught"); 
return; 
}else if(sel==1){ 
int iArray[]=new int[4]; 
iArray[1]=3; 


public static void main(String args[]){ 
try{ 
Proc(0); 
Proc(1); 
}catch(ArrayIndexOutOfBoundsException e){ 
System.out.println("Catch"+e); 
}finally{ 
System.out.println("in Proc finally"); 


执行结果: 
In.Situation() 
no Exception caught 
【14】    
in Proc finally 
答案:In Situation 1 
(15)当使用Thread t=new Thread(r)创建一个线程时,表达式:r instanceof Thread的值为 【15】    。  答案:false 

上一页  [1] [2] [3] [4] 

责任编辑:cyth

文章搜索:
 相关文章
热点资讯
资讯快报
热门课程培训