10下半年Java机考试题_第1页
10下半年Java机考试题_第2页
10下半年Java机考试题_第3页
10下半年Java机考试题_第4页
10下半年Java机考试题_第5页
已阅读5页,还剩10页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1 20102010 年年 下下 全国信息技术水平考试计算机程序设计技术水平证书 全国信息技术水平考试计算机程序设计技术水平证书 JAVAJAVA 语言 语言 考试试卷考试试卷 第一大题 单选题第一大题 单选题 30 分 1 1 分 下列叙述中正确的是 A Java 程序经编译后会产生 machine code B Java 程序经编译后会产生 byte code C Java 程序经编译后会产生 DLL D 以上都不正确 2 1 分 下列说法中正确的是 A 类中的构造方法声明不可省略 B 构造方法必须与类同名 构造方法返回值为 void C 构造方法在一个对象被 new 时执行 D 一个类只能定义一个构造方法 3 1 分 JDBC 常用的类和接口都包含在 包中 A java sql B java awt C java lang D java swing 4 1 分 执行下列程序后 C 的值是 public class Test public static void main String arg int a 0 c 0 do c a a 1 while a 0 A 0 B 1 C 1 D 死循环 5 1 分 若有 int 型 public 成员变量 MAX LENGTH 该值保持为常数 100 则定义 这个变量的语句是 A public int MAX LENGTH 100 B final int MAX LENGTH 100 2 C public const int MAX LENGTH 100 D public final int MAX LENGTH 100 6 1 分 在程序中 import package class 出现的正确顺序是 A import package class B package import class C package class import D import class package 7 1 分 下列方法中可以用来创建一个新线程的是 A 实现 java lang Runnable 接口并重写 start 方法 B 实现 java lang Runnable 接口并重写 run 方法 C 实现 java lang Thread 类并重写 sleep 方法 D 实现 java lang Thread 类并重写 start 方法 8 1 分 下列程序的输出结果是 public class Test public static void main String args String a new String A String b new String B oper a b System out println a b static void oper String c String d c concat B d c A A A B 编译正确 运行时将产生错误 C A B D AB AB 9 1 分 Java 的字符类型采用的是 Unicode 编码方案 每个 Unicode 码占用 个比特位 A 8 B 16 C 32 D 64 10 1 分 下列程序段输出的结果是 3 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 out println two A default B default zero C 程序编译出错 D 程序运行正确 但没有输出 11 1 分 下列程序输出的结果是 public class Test public static void main String args static int x new int 15 System out println x 5 A 编译出错 B 编译通过 但运行时有错 C 输出 0 D 输出 null 12 1 分 给出如下代码 class Test private int m public static void fun some code 下列选项中 能使成员变量 m 被函数 fun 直接访问的是 A 将 private int m 改为 protected int m B 将 private int m 改为 public int m 4 C 将 private int m 改为 static int m D 将 private int m 改为 int m 13 1 分 给出如下代码 请问 x 处于什么范围时将打印字符串 second if x 5 System out println first else if x 5 System out println second else System out println third A x 5 B x 5 C x 5 D x 5 14 1 分 一个线程的 run 方法包含以下语句 假定线程没有被打断 则下列说 法中正确的是 1 try 2 sleep 10 3 catch InterruptedException e A 不能通过编译 因为在 run 方法中可能不会捕捉到异常 B 在第 2 行 线程将暂停运行 正好在 10 毫秒后继续运行 C 在第 2 行 线程将暂停运行 最多在 10 毫秒内将继续运行 D 在第 2 行 线程将暂停运行 将在 10 毫秒后的某一时刻继续 运行 15 1 分 关于以下代码 下列说法中正确的是 1 abstract class AbstractOne 2 abstract int getInt 3 4 public class Test extends AbstractOne 5 private int x 1 6 private int getInt 7 return x 8 A 编译成功 B 编译成功 但会导致运行时错误 C 编译无法通过 第 2 行有错 5 D 编译无法通过 第 6 行出错 16 1 分 下列方法中不能成为方法 public void add int a 重载方法的是 A public int add int a B public void add long a C public void add int a int b D public void add float a 17 1 分 下列程序执行后将有 个字节被写入到文件 myfile txt 中 import java io public class Test public static void main String args try FileOutputStream fos new FileOutputStream myfile txt DataOutputStream dos new DataOutputStream fos dos writeInt 3 dos writeChar 1 dos close fos close catch IOException e A 3 B 5 C 6 D 不确定 与软硬件环境相关 18 1 分 下列程序段输出的结果是 public class Test static int i public static void main String argv System out println i A 有错误 变量 i 没有初始化 B null C 1 D 0 19 1 分 A 派生出子类 B B 派生出子类 C 并且在 Java 源代码中有如下声明 1 A a0 new A 2 A a1 new B 6 3 A a2 new C 下列说法中正确的是 A 只有第 1 行能通过编译 B 第 1 2 行能通过编译 但第 3 行编译出错 C 第 1 2 3 行能通过编译 但第 2 3 行运行时出错 D 第 1 行 第 2 行和第 3 行的声明都是正确的 20 1 分 下列说法中正确的是 A try 语句可以单独存在 不需要其他的附加语句 B try 语句不能单独存在 后面必须要和 catch 或 finally 语句 配合使用 C 在 try 语句后面的 catch 语句只能有一句 D finally 语句的作用是用来完成一些不能完成的工作 21 1 分 当点击 Applet 中一个按钮控件时 下列哪个对象将会被创建 A PaintEvent B TextEvent C ActionEvent D KeyEvent 22 1 分 下列程序输出的结果是 class Parent String one two public Parent String a String b one a two b public void print System out println one public class Child extends Parent public Child String a String b super a b public void print System out println one to two public static void main String arg 7 Parent p new Parent south north Parent t new Child east west p print t print A south east B south to north east to west C south to north east D south east to west 23 1 分 若变量 result 是一个 boolean 型的变量 则下列表达式合法的是 A result True B if result do something C if result 0 so something D result 1 24 1 分 下列类中可以作为 FilterInputStream 类的构造方法参数的是 A FilterOutputStream 类 B File 类 C InputStream 类 D RandomAccessFile 类 25 1 分 阅读下面的代码片断 1 String str null 2 if str null 4 5 else if str null 7 8 else System out println end 8 导致错误的行号是 A line 1 B line 2 C line 5 D line 8 26 1 分 下列关键字中能阻止一个类被继承的是 A final B protected C private D abstract 27 1 分 若有如下类定义 abstract class Shape abstract void draw 那么 在试图编译下面的类定义时会发生什么情况 class Square extends Shape A 都可以成功编译 B Shape 可以编译 而 Square 不能 C Square 可以编译 而 Shape 不能 D Shape 和 Square 都不能编译 28 1 分 下列程序的输出结果是 class C1 static int j 0 public void method int a j class Test extends C1 public int method return j public void result method j System out println j method public static void main String args new Test result 9 A 0 B 1 C 2 D 3 29 1 分 下列程序的输出结果是 class Test static void change String s s s replace j l public static void main String args String s java change s System out println s A 编译错误 B lava C 运行时出现异常 D java 30 1 分 下列程序的输出结果是 public class Test static int I 0 void fun I public static void main String args Test obj1 new Test Test obj2 new Test obj1 fun obj2 fun System out println obj1 I A 编译错误 B 6 C 1 D 2 第二大题 实践题 编程题 第二大题 实践题 编程题 70 分 1 20 分 程序功能 接受一个小于 1000 的正整数参数 返回 3 位字符串数 据格式 整数位数不足 3 位 前面补 0 例如输入 7 返回 007 输入 32 返回 032 输入 899 返回 899 等 提示 10 程序架构如下 public class Test1 获得任意一个小于 1000 的正整数的 3 位字符串格式 public String GetStr int n public static void main String args Test1 t new Test1 System out println test1 GetStr 7 System out println test1 GetStr 32 System out println test1 GetStr 899 备注 考生按照系统提示目录保存试题文件 每道试题建立一个文 件夹 文件夹名为题目编号 文件夹中的文件命名参照提示所给的 程序架构 例 第一题的试题文件夹名为 1 文件名为 Test1 java 对 应的字节码文件为 Test1 class 2 25 分 程序功能 创建一个能装 5 个水果的篮子 水果有苹果 橘子和 香蕉 从篮子中一个一个把水果拿出来 并打印出该水果的名称 提示 1 用数组来表示篮子 提示 2 创建水果类 该类中有一个抽象方法 GetName 用来输出 水果的名称 提示 3 分别创建水果类的 3 个子类 苹果 橘子和香蕉类 分别 实现 GetName 方法 程序架构如下 public class Test2 public Test2 public static void main String args fruit fruits new fruit 5 fruits 0 new Apple fruits 1 new Orange fruits 2 new Banana fruits 3 new Apple fruits 4 new Orange for int i 0 i 1000 13 s 参数超范围 else if n 100 s String valueOf n else if n 10 s 0 String valueOf n else if n 1 s 00 String valueOf n else s 参数超范围 return s public static void main String args Test1 t new Test1 System out println t GetStr 7 System out println t GetStr 32 System out println t GetStr 899 System out println t GetStr 8994 System out println t GetStr 3 第 2 题参考程序 25 分 abstract class fruit public abstract String GetName class Apple extends fruit public String GetName return Apple class Orange extends fruit public String GetName return Orange class Banana extends fruit public String GetName return Banana public class Test2 public Test2 public static void main String args fruit fruits new fruit 5 fruits 0 new Apple fruits 1 new Orange fruits 2 new Banana fruits 3 new Apple fruits 4 new Orange for int i 0 i 5 i 14 System out println fruits i GetName 第 3 题参考程序 25 分 import java io public class Test3 public Test3 public static void main String args try Customer cust1 new Customer 001 Jack 010 83488475 Beijing Customer cust2 new Customer 002 Rose 021 87676364 Shanghai Customer cust3 new Customer 003 Mick 020 83488475 Guangzhou FileOutputStream fos new FileOutputStrea

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论