Java模拟试题(三)_第1页
Java模拟试题(三)_第2页
Java模拟试题(三)_第3页
Java模拟试题(三)_第4页
Java模拟试题(三)_第5页
已阅读5页,还剩2页未读 继续免费阅读

下载本文档

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

文档简介

Java 模拟试题 三 模拟试题 三 一 判断题 24 1 如果 p 是父类 Parent 的对象 而 c 是子类 Child 的对象 则语句 c p 是 正确的 F 2 当一个方法在运行过程中产生一个异常 则这个方法会终止 但是整个程序 不一定终止运行 T 3 用 可以实现字符串的拼接 用 可以从一个字符串中去除一个字符子串 F 4 使用方法 length 可以获得字符串或数组的长度 F 5 一个容器中可以混合使用多种布局策略 T 6 Java 中 并非每个事件类都只对应一个事件 T 7 Java 的源代码中定义几个类 编译结果就生成几个以 class 为后缀的字节 码文件 T 8 Java Applet 是由独立的解释器程序来运行的 F 9 Java Applet 只能在图形界面下工作 T 10 Java 的字符类型采用的是 ASCII 编码 F 11 Java 的各种数据类型占用固定长度 与具体的软硬件平台环境无关 T 12 Applet 是一种特殊的 Panel 它是 Java Applet 程序的最外层容器 T 13 System 类不能实例化 即不能创建 System 类的对象 T 14 用户自定义的图形界面元素也可以响应用户的动作 具有交互功能 F 15 Java 中数组的元素可以是简单数据类型的量 也可以是某一类的对象 T 16 Java 中的 String 类的对象既可以是字符串常量 也可以是字符串变量 F 二 选择题 24 1 编译运行以下程序后 关于输出结果的说明正确的是 C public class Conditional public static void main String args int x 4 System out println value is x 4 99 9 9 A 输出结果为 value is 99 99 B 输出结果为 value is 9 C 输出结果为 value is 9 0 D 编译错误 2 以下声明合法的是 B A default String s B public final static native int w C abstract double d D abstract final double hyperbolicCosine 3 关于以下 application 的说明 正确的是 C 1 class StaticStuff 2 3 static int x 10 4 static x 5 5 public static void main String args 6 7 System out println x x 8 9 static x 3 10 A 4 行与 9 行不能通过编译 因为缺少方法名和返回类型 B 9 行不能通过编译 因为只能有一个静态初始化器 C 编译通过 执行结果为 x 5 D 编译通过 执行结果为 x 3 4 关于以下程序代码的说明正确的是 D 1 class HasStatic 2 private static int x 100 3 public static void main String args 4 HasStatic hs1 new HasStatic 5 hs1 x 6 HasStatic hs2 new HasStatic 7 hs2 x 8 hs1 new HasStatic 9 hs1 x 10 HasStatic x 11 System out println x x 12 13 A 5 行不能通过编译 因为引用了私有静态变量 B 10 行不能通过编译 因为 x 是私有静态变量 C 程序通过编译 输出结果为 x 103 D 程序通过编译 输出结果为 x 102 5 以下选项中循环结构合法的是 C A while int i 7 i System out println i is i B int j 3 while j System out println j is j C int j 0 for int k 0 j k 10 j k System out println j is j k is k D int j 0 do System out println j is j if j 3 continue loop while j 10 6 类 Test1 定义如下 1 public class Test1 2 public float aMethod float a float b 3 4 将以下哪种方法插入行 3 是不合法的 B A public float aMethod float a float b float c B public float aMethod float c float d C public int aMethod int a int b D private float aMethod int a int b int c 7 类 Test1 Test2 定义如下 1 public class Test1 2 public float aMethod float a float b throws 3 IOException 4 5 public class Test2 extends Test1 6 7 将以下哪种方法插入行 4 是不合法的 A A float aMethod float a float b B public int aMethod int a int b throws Exception C public float aMethod float p float q D public int aMethod int a int b throws IOException 8 关于以下程序段 正确的说法是 C 1 String s1 abc def 2 String s2 new String s1 3 if s1 s2 4 System out println succeeded 5 if s1 equals s2 6 System out println equals succeeded A 行 4 与行 6 都将执行 B 行 4 执行 行 6 不执行 C 行 6 执行 行 4 不执行 D 行 4 行 6 都不执行 三 改错题 20 判断下面的程序片断是否正确 若有错 指出错在哪里并改正 若正确 打 1 class parent private int mine int getMine return mine class child extends parent int mine int getMine return super getMine T 2 class AmIWrong int data1 data2 AmIWrong data1 1 AmIWrong int d data2 d this 3 interface MyInterface void method1 abstract class Parent implements MyInterface class Child extends Parent void method1 System out println I am implemented now 4 public static void main String args try char ch char System in read 其他语句 catch Exception e return catch IOException e System out println e toString 5 public class AmIWrong implements Runnable Thread mt Thread this mt start void run System out println I am alive now 四 程序阅读 20 1 阅读以下程序段 class Parent void printMe System out println parent class Child extends Parent void printMe System out println child void printAll super printMe this printMe printMe public class Test this public static void main String args Child myC new Child myC printAll 输出结果为 2 以下程序段的输出结果为 public class EqualsMethod public static void main String args Integer n1 new Integer 47 Integer n2 new Integer 47 System out print n1 n2 System out print System out println n1 n2 3 已有 Bird 类的定义如下 package abcde public class Bird protected static int referenceCount 0 public Bird referenceCount protected void fly static int getReCount return referenceCount 有类 Nightingale 的定义如下 请写出它的输出结果 package singers class Nightingale extends abcde Bird Nightingale referenceCount public static void main String args System out print Before referenceCount Nightingale florence new Nightingale System out println After referenceCount florence fly 4 以下程序段的输出结果为 class Cruncher void crunch int i System out println int version

温馨提示

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

评论

0/150

提交评论