[计算机类试卷]国家二级(JAVA)笔试模拟试卷166及答案与解析.doc

上传人:deputyduring120 文档编号:503711 上传时间:2018-11-29 格式:DOC 页数:20 大小:57KB
下载 相关 举报
[计算机类试卷]国家二级(JAVA)笔试模拟试卷166及答案与解析.doc_第1页
第1页 / 共20页
[计算机类试卷]国家二级(JAVA)笔试模拟试卷166及答案与解析.doc_第2页
第2页 / 共20页
[计算机类试卷]国家二级(JAVA)笔试模拟试卷166及答案与解析.doc_第3页
第3页 / 共20页
[计算机类试卷]国家二级(JAVA)笔试模拟试卷166及答案与解析.doc_第4页
第4页 / 共20页
[计算机类试卷]国家二级(JAVA)笔试模拟试卷166及答案与解析.doc_第5页
第5页 / 共20页
点击查看更多>>
资源描述

1、国家二级( JAVA)笔试模拟试卷 166及答案与解析 1 下列语句中,可以作为无限循环语句的是 ( A) for(;) ( B) for(int i=0; i 10000; i+) ( C) while(false) ( D) dowhile(false) 2 阅读下面程序 public class Test implements Runnable private int x=0; private int y=0; boolean flag=true; public static void main(Stringargs) Test r=new Test(); Thread t1=new T

2、hread(r); Thread t2=new Thread(r); t1.start(); t2.start(); public void run() while(flag) x+; y+; System.out.println(“(“+x+“,“+y+“)“); if(x =10) flag=false; 下列对程序运行结果描述的选项中,正确的是 ( A)每行的 (x,y)中,可能有 xY;每一对 (x,y)值都出现两次 ( B)每行的 (x,y)中,可能有 xy;每一对 (x,y)值仅出现一次 ( C)每行的 (x,y)中, x=y;每一对 (x,y)值都出现两次 ( D)每行的 (x,

3、y)中, x=y;每一对 (x,y)值都出现一次 3 在下面程序的空白处,应填入的正确选项是 import java.io.*; public class writeInt public static void main(Stringa) int myArray=10,20,30,40; try DataoutputStream dos=new DataoutputStream(new FileOutputStream(“ints.dat“); for(int i=0; i myArray.length;i+)dos.writeInt(myArrayi); dos._; System.out.

4、println(“Have written binary file ints.dat“); catch(IOException ioe)System.out.println(“IO Exception“); ( A) start() ( B) close() ( C) read() ( D) write() 4 为了将 HelloApplet(主类名为 HelloApplet.class)嵌入在 greeting.html文件中,应该在下面 greeting.html文件的横线处填入的代码是 HTML HEADTITLE Greetings /TITLE /HEAD BODY APPLET_/

5、APPLET /BODY /HTML ( A) HelloApplet.class ( B) CODE=“HelloApplet.class“ ( C) CODE=“HelloApplet.class“WIDTH=150 HEIGHT=25 ( D) CODE=“HelloApplet.class“VSPACE=10 HSPACE=10 5 阅读下面程序 public void test() try sayHello(); System.out.println(“hello“); catch(ArrayIndexOutOfBoundException e) System.out.println

6、(“ArrayIndexOutOfBoundException“); catch(Exception e) System.out.println(“Exception“); finally System.out.println(“finally“); 如果 sayHello()方法正常运行,则 test()方法的运行结果将是 ( A) Hello ( B) ArraylndexOutOfBondsException ( C) Exception Finally ( D) Hello Finally 6 下面程序的功能是统计字符串中 “array”的个数,在程序的空白处应填入的正确选项是 pub

7、lic class FindKeyWords public static void main(Stringargs) String text=“An array is a data structur that stores a collection of“ +“values of the same type. You access each indMdual value“ +“through an integer index. For example,if a is an array“ +“of inergers, then aiis the ith integer in the array

8、“; int arrayCount=0; int index=-1; String arrayStr=“array“; index=text.indexOf(arrayStr); while(index =0) +arrayCount; index+=arrayStr.length(); index=text.indexOf(arrayStr, index); System.out.println(“the text contains“+arrayCount+“arrays“); ( A) ( B) = ( C) = ( D) = 7 在下面程序的空白处,应填入的正确选项是 import ja

9、va.io.*; public class ObjectStreamTest public static void main(String args)throws IOExeeption ObjectoutputStream oos=new ObjectOutputStream(new FileOutputStream(“serial.bin“); java.util.Date d=new java.util.Date(); oos. _(d); ObjectInputStream ois=new ObjecttInputStream(new FileInputStream(“serial.b

10、in“); try java.util.Date restoredDate=(java.util.Date)ois.readObject(); System.out.println(“read object back from serial.bin file: “+restoredDate); catch(classNotFoundException cnf) System.out.println(“class not found“); ( A) WriterObject ( B) write ( C) BufferedWriter ( D) writerObject 8 下列数据结构中,属于

11、非线性结构的是 ( A)循环队列 ( B)带链队列 ( C)二叉树 ( D)带链栈 9 下列数据结构中,能够按照 “先进后出 ”原则存取数据的是 ( A)循环队列 ( B)栈 ( C)队列 ( D)二叉树 10 对于循环队列,下列叙述中正确的是 ( A)队头指针是固定不变的 ( B)队头指针一定大于队尾指针 ( C)队头指针一定小于队尾指针 ( D)队头指针可以大于队尾指针,也可以小于队尾指针 11 算法的空间复杂度是指 ( A)算法在执行过程中所需要的计算机存储空间 ( B)算法所处理的数据量 ( C)算法程序中语句或指令的条数 ( D)算法在执行过程中所需要的临时工作 单元数 12 软件设

12、计中划分模块的一个准则是 ( A)低内聚低耦合 ( B)高内聚低耦合 ( C)低内聚高耦合 ( D)高内聚高耦合 13 下列选择项中不属于结构化程序设计原则的是 ( A)可封装 ( B)自顶向下 ( C)模块化 ( D)逐步求精 14 数据库管理系统是 ( A)操作系统的一部分 ( B)在操作系统支持下的系统软件 ( C)一种编译系统 ( D)一种操作系统 15 在 E-R图中,用来表示实体联系的图形是 ( A)椭圆形 ( B)矩形 ( C)菱形 ( D)三角形 16 用于设置组件大小的方法是 ( A) paint() ( B) setSize() ( C) getSize() ( D) re

13、paint() 17 单击窗口内的按钮时,产生的事件是 ( A) MouseEvent ( B) WindowEvent ( C) ActionEvent ( D) KeyEvent 18 AWT中用来表示对话框的类是 ( A) Font ( B) Color ( C) Panel ( D) Dialog 19 下列运算符中,优先级最高的是 ( A) += ( B) = ( C) MAX_PRIORITY最大优先级,通常为 10; NORM_PRIORITY普通优先级,默认值 为 5。一般情况下,主线程具有普通优先级。 46 【正确答案】 run() 【试题解析】 创建线程有两种方法:实现 java.lang.Runnable 接 El和继承Thread 类并重写 run()方法。 Runnable接口中只定义了一个抽象方法 run(),因此要实现 run()方法。 47 【正确答案】 MouseEvent 【试题解析】 mouseDragged()方法是 MouseMotionListener接口中的抽象方法,其原型为 voidmouseDragged(MouseEvent

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

当前位置:首页 > 考试资料 > 职业资格

copyright@ 2008-2019 麦多课文库(www.mydoc123.com)网站版权所有
备案/许可证编号:苏ICP备17064731号-1