计算机等级考试二级Java模拟试题[2] |
|
www.nanhushi.com 佚名 不详 |
26.下列不是 InputStream 子类的是____。 A、文件输入流 FileInputStream B、对象输入流 ObjectInputStream C、字符输入流 CharInputStream D、压缩文件输入流 ZipInputStream 27.下列方法中可以用来创建一个新线程的是____。 A、实现java.lang.Runnable 接口并重写 start()方法 B、实现java.lang.Runnable 接口并重写 run()方法 C、继承java.lang.Thread 类并重写 run()方法 D、实现java.lang.Thread 类并实现 start()方法 28.下列关于 Java Application 与 Applet 的说法中,正确的是____。 A、都包含 main() 方法 B、都通过“appletviewer”命令执行 C、都通过“javac”命令编译 D、都嵌入在 HTML 文件中执行 来源:www.examda.com 29.当启动 Applet 程序时,首先调用的方法是____。 A、stop() B、init() C、start() D、destroy() 30.下列关于线程优先级的说法中,正确的是____。 A、线程的优先级是不能改变的 B、线程的优先级是在创建线程时设置的 C、在创建线程后的任何时候都可以设置 D、B 和 C
31.当浏览器重新返回 Applet 所在页面时,将调用 Applet 类的方法是____。 A、start() B、init() C、stop() D、destroy() 32.按照 Java 的标识符命名规范,下列表示一个类的标识符正确的是____。 A、Helloworld B、HelloWorld C、helloworld D、helloWorld 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行 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.out.println("Hello"); } } } A、sleep(1000) InterruptedException B、t.sleep(1000) InterruptedException C、Thread.sleep(1000) RuntimeException D、Thread.sleep(1000) InterruptedException 35.阅读下列代码后 public class Person{ int arr[]=new int[10]; public static void main(String args[]){ System.out.println(arr[1]); } } 正确的说法是 A、编译时将产生错误 B、编译时正确,运行时将产生错误 C、输出零 D、输出空
二、填空题(每空2分,共计30分) 1.某二叉树中度为2的结点有18个,则该二叉树中有____个叶子结点。 2.在面向对象方法中,类的实例称为____。 3.诊断和改正程序中错误的工作通常称为____。 4.在关系数据库中,把数据表示成二维表,每一个二维表称为____。 5.问题处理方案的正确而完整的描述称为____。 6.面向对象的语言将客观世界都看成由各种对象组成,共同特征和行为的对象组成类, 类是变量和____的集合体。 7.Java 源文件中最多只能有一个____类,其他类的个数不限。 8.在 Java 中所有实现的多维数组,实际上是由一维数组构成的____。 9.每个Applet程序必须有一个类是____类的子类。 10.线程在生命周期中要经历 5 种状态,分别是新建状态、可运行状态、运行状态、____状 态和终止状态。 11.FileInputStream 是字节流;BufferedWriter 是字符流;ObjectOutputStream 是____。 12.break 语句最常见的用法是 switch 语句中,通过 break 语句退出 switch 语句, 使程序从整个 switch 语句后面的____开始执行。 13.请阅读下列程序代码,然后将程序的执行结果补充完整。 程序代码: public class throwsException{ static void Proc(int sel) throw 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 Situation0 no Exception caught ____ in Proc finally
|
|
|
文章录入:杜斌 责任编辑:杜斌 |
|
上一篇文章: 计算机等级考试二级Java模拟试题[1] 下一篇文章: Java程序员模拟题及分析汇总 |
【字体:小 大】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口】 |
|
|