




已阅读5页,还剩11页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
考试场次 2015 01 月月考 01 月 29 日 JAVA 试卷名称 2015 年 01 月 JSD JSD1412 1 运行下面的程序 int a 100 int b 200 a a b b a b a a b System out println a a b b 输出的结果是 A a 100 b 300 B a 100 b 200 C a 200 b 100 D a 300 b 200 正确答案 C 2 下面关于数组的声明语句中 有编译错误的是 A int arr new int 1 2 3 B int arr null arr 1 2 3 4 5 C int arr new int 1 2 3 4 5 6 D int arr new int 2 正确答案 B 3 分析如下代码 输出结果为 public static void main String args int i 0 boolean re false re i i 2 true false System out println i i re re A i 1 re true B i 0 re true C i 1 re false D i 0 re false 正确答案 A 4 请看下列代码 interface Foo int bar public class Sprite public int fubar Foo foo return foo bar public void testFoo fubar 使类 Sprite 编译通过 在处应填入的代码是 A Foo public int bar return 1 B new Foo public int bar return 1 C new Foo public int bar return 1 D new class Foo public int bar return 1 正确答案 C 5 程序的执行结果是 public class Test public static void main String args String str1 new String abc String str2 new String abc String str3 str1 if str1 equals str2 System out println true else System out println false if str1 str3 System out println true else System out println false A true true B true false C false true D false false 正确答案 A 6 下列代码的输出结果是 public class StaticFoo int num static int x public static void main String args StaticFoo foo1 new StaticFoo foo1 num foo1 x StaticFoo foo2 new StaticFoo foo2 num foo2 x StaticFoo foo3 new StaticFoo foo3 num foo3 x StaticFoo x System out print foo3 num System out println foo3 x A 3 3 B 1 3 C 3 4 D 1 4 正确答案 D 7 运行下面的程序 Calendar c Calendar getInstance c set Calendar YEAR 2012 c set Calendar MONTH Calendar SEPTEMBER c set Calendar DATE 31 SimpleDateFormat sdf new SimpleDateFormat yyyy MM dd System out println sdf format c getTime 输出的结果是 A 2012 10 1 B 2012 10 01 C 2012 09 30 D 2012 9 30 正确答案 B 8 下列关于 JVM 说法 错误的是 A JVM 通过专门的线程实现内存的回收 B 使用 java 命令时 可以通过参数来设置分配 JVM 的内存大小 C JRE 包括 JVM 及 Java 核心类库 D 目前主流版本 JVM 通过纯解释的方式运行 Java 字节码 正确答案 D 9 请看下列代码 public class Plant private String name public Plant String name this name name public String getName return name class Tree extends Plant public void growFruit public void dropLeaves 下列说法正确的是 A 在 Tree 类中添加代码 public Tree Plant 编译将通过 B 在 Plant 类中添加代码 public Plant Tree 编译将通过 C 在 Plant 类中添加代码 public Plant this fern 编译将通过 D 在 Plant 类中添加代码 public Plant Plant fern 编译将通过 正确答案 C 10 运行下列程序 String str java java java String str1 java int index 0 while index str indexOf str1 index 1 System out print index index str1 length 控制台输出的结果是 A 1 8 17 B 2 9 18 C 5 12 21 D 6 13 22 正确答案 B 11 下列语句创建对象的总个数是 String s a b c d e A 1 B 2 C 3 D 4 正确答案 A 12 下列代码的输出结果是 int j 0 for int i 0 i 100 i j j System out println j A 0 B 99 C 100 D 101 正确答案 A 13 下列代码编译和运行的结果是 public class Foo public static void main String args java util List list new java util ArrayList list add new B list add new C for A a list a x a y interface A void x class B implements A public void x public void y class C extends B public void x A 代码运行没有输出 B 运行时抛出异常 C 代码 a y 行 编译错误 D 代码 java util List list new java util ArrayList 行 编译错误 正确答案 C 14 下面的程序可以输出 1 100 内前 10 个 3 的倍数 for int i 1 count 0 i 10 break B if count 10 break C if count 10 continue D if count 10 continue 正确答案 B 15 请看下列代码 public class Person private String name public Person String name this name name public boolean equals Person p return p name equals this name 下列说法正确的是 A Person 类的 equals 方法没有覆盖 Object 类的 equals 方法 B 编译错误 因为私有属性不能在 equals 方法中被访问 C 基于 Hash 的数据结构可以正确工作 但是 Person 类必须覆盖 hashCode 方法 D 当向 Set 集合中添加 Person 对象时 equals 方法中的 return 语句能避免重复 正确答案 A 16 有变量声明如下 short b 120 下列语句中 错误的是 A short s b B int i b C byte s1 b D long l b 正确答案 C 17 Java 程序的执行过程中用到一套 JDK 工具 其中 javac exe 是指 A Java 语言编译器 B Java 字节码解释器 C Java 文档生成器 D Java 类分解器 正确答案 A 18 以下程序的输出结果是 public class Super public Super System out println Super public class Sub extends Super public Sub System out println Sub public static void main String args Super fc new Super Sub cc new Sub A Super Super Sub B Super Sub C Sub Super D Super Sub Sub 正确答案 A 19 下列代码的输出结果是 public static void main String args int one new int 4 6 8 int two new int 1 3 5 7 9 System arraycopy one 1 two 2 2 System out println Arrays toString two A 1 3 7 4 6 B 1 3 5 7 8 C 1 3 5 6 9 D 1 3 6 8 9 正确答案 D 20 实现 Point 类的 equals 方法 具体逻辑为 成员变量 x 和 y 分别相等的 Point 对象 被视为相等 public class Point private int x private int y public boolean equals Object obj 填入代码 插入代码 处应填入的代码正确的是 A if obj x this x obj y this y return true return false B if obj x this x return false C if obj instanceof Point return false if Point obj x Point obj y return false D if obj instanceof Point return false if Point obj x this x return false 正确答案 D 21 下列数组声明语句中 错误的是 A int arr new int B int arr new int C int arr D int arr new int 2 正确答案 B 22 下面关于 interface 叙述错误的是 A 一个 interface 可以继承多个 interface B 接口中的方法可以由 private 修饰 C interface 中可以定义 static final 常量 D interface 中可以无任何方法定义 正确答案 B 23 关于下列代码说法不正确的是 10 interface Foo 11 int bar 12 13 14 public class Beta 15 16 class A implements Foo 17 public int bar return 1 18 19 20 public int fubar Foo foo return foo bar 21 22 public void testFoo 23 24 class A implements Foo 25 public int bar return 2 26 27 28 System out println fubar new A 29 30 31 public static void main String argv 32 new Beta testFoo 33 34 A 编译错误 B 运行代码输出 2 C 如果删除 16 17 18 行 运行代码应然输出 2 D 如果删除 24 25 26 行 运行代码输出 1 正确答案 A 24 下列代码的输出结果是 class Cup class PoisonCup extends Cup public void takeCup Cup c if c instanceof PoisonCup System out println Inconceivable else if c instanceof Cup System out println Dizzying intellect else System exit 0 public class TestCup public static void main String args Cup cup new PoisonCup PoisonCup poison new PoisonCup poison takeCup cup A Inconceivable B Dizzying intellect C 代码正常运行 但是无输出 D 抛出运行时异常 正确答案 A 25 下列关于 HashMap 的方法描述正确的是 A containsKey Object key 判断集合中是否包含指定的 Value B containsValue Object value 判断集合中是否包含指定的 Key C get Object key 返回与参数 Key 所对应的 Value 对象 如果不存在则返回 null D put K key V value 将 Key Value 对存入 Map 如果在集合中已经包含该 Key 则操 作将替换该 Key 所对应的 Value 返回值为该 Key 当前所对应的 Value 如果没有则返回 null 正确答案 C 26 查看如下代码 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 正确答案 D 27 在 Java 语言中 下列说法正确的是 A Java 访问修饰符按照访问范围由低到高的排列顺序是 public default protected private B private 可以用于外部类的声明 C 一个 Java 源文件中声明为 public 的外部类只能有一个 D protected 声明的方法不可以被子类重写 正确答案 C 28 下列代码运行的结果是 public class Base public static final String FOO foo public static void main String args Base b new Base Sub s new Sub System out print Base FOO System out print Sub FOO System out print b FOO System out print s FOO System out print Base s FOO class Sub extends Base public static final String FOO bar A foofoofoofoofoo B foobarfoobarbar C foobarfoofoofoo D foobarfoobarfoo 正确答案 D 29 在 Java 中 Integer MAX VALUE 表示 A double 型最大值 B int 最大值 C long 型最大值 D char 型最大值 正确答案 B 30 请看下列代码 public static void main String args Calendar c Calendar getInstance c set Calendar YEAR 2013 c set Calendar MONTH Calendar FEBRUARY c set Calendar DATE 28 在处填入将 Calendar 表示的日期转换为 Date 表示的日期 A Date d c getDate B Date d c getCalendar C Date d c getNow D Date d c getTime 正确答案 D 31 题目代码的功能为 输出每个字符在一个字符串中出现的次数 不区分大小写 String str ewrwqFrewqfsadfdsfdsfs str str toLowerCase int max length 0 while str length 0 插入代码 A int length str length char first str charAt 0 String strNew str replaceAll String valueOf first if length strNew length max length length strNew length System out println first max length B int length str length char first str charAt 0 String strNew str replaceAll String valueOf first if length strNew length max length length strNew length str strNew System out println first max length C int length str length String first str substring 0 1 String strNew str replaceAll first if length strNew length max length length strNew length str strNew System out println first max length D int length str length String first str substring 0 1 String strNew str replaceAll first if length strNew length max length length strNew length System out println first max length 正确答案 BC 32 请看下列代码 public class Old public static Object get List list return list get 0 以下选项调用 get 方法 能编译通过的是 A Object o Old get new LinkedList B Object o Old get new LinkedList C String s Old get new LinkedList D String s String Old get new LinkedList 正确答案 AD 33 下列赋值语句中 会有编译错误的是 A int a 8888888888 B char b 1000 300 C byte c 100 30 D int d a b c 正确答案 AC 34 所谓 水仙花 数是一个整数等于各位数字立方的和 例如 153 1 1 1 5 5 5 3 3 3 下面的程序用于输出 2 1000 内的水仙花数 for int n 2 n 0 int t n1 10 s t t t n1 10 B int s 0 n1 n while n1 0 int t n1 10 s t t t n1 10 C int s 0 for int n1 n n1 0 n1 10 int t n1 10 s t t t D int s 0 for int n1 n n1 0 n1 10 int t n1 10 s t t t 正确答案 AC 35 请看下列代码 class One public One foo return this class Two extends One public One foo return this class Three extends Two 下列选项中的代码 放置在处无编译错误的是 A public void foo B public Object foo return this C public Two foo return this D public One foo return this 正确答案 CD 36 在 Java 语言中 下列说法正确的是 A StringBuffer 和 StringBuilder 的区别在于 StringBuffer 是线程安全的而 StringBuilder 不是 B String 是不可变对象 而 StringBuffer 中封装的字符串数据是可以动态改变的 C 判断两个 StringBuilder 对象的字符序列是否相同 可以调用其 equlas 方法进行比较 D String 的重写了 equals 方法 重写的逻辑是 字符序列相同的 String 对象 equals 方 法返回 true 正确答案 ABD 37 下列关于 HashMap 的描述正确的是 A HashMap 的 Key 和 Value 是以链表的方式存入对应的 bucket B HashMap 的查找方式是获取 Key 的 hashCode 值 通过 hash 算法确定存储的 bucket 调 用 equals 方法依次与 bucket 中的 Key 进行比较 C 放入 HashMap 集合中的元素按照 key 的自然顺序排序 D HashMap 中的 key 是不可以的重复的 正确答案 ABD 38 在 Java 语言中 下列说法正确的是 A 一个接口可以继承多个接口 B 一个类可以继承多个类 C 一个类可以实现多个接口 D 一个类可以有多个子类 正确答案 ACD 39 请看下列代码 public abstract class Shape int x int y public abstract void draw public void setAnchor int x int y this x x this y y 下列选项中能正确使用 Shape 类的是 A public class Circle implements Shape private int radius B public abstract class Circle extends Shape private int radius C public class Circle extends Shape private int radius public void draw D public class Circle extends Shape private int radius public void draw code here 正确答案 BD 40 在处 填入下列代码编译正确的是 public void foo int x A foreach int z x System out println z B for int z x System out println z C while x hasNext System out println x next D for int i 0 i x length i System out println x i 正确答案 BD 41 阅读理解 public class A public A System out print A public A String s System out print s public void fun System out println A fun public class B extends A public B System out print B public B String s super s public void fun System out println B fun public void sun System out println B sun public static void Main A a new B a fun 1 下列关于上述代码中构造方法的描述 错误的是 A 实例化对象 a 时 将默认调用父类的无参构造方法 B 类 B 中使用 super 关键字 是为了调用父类的含有一个参数的构造方法 C 实例化对象 a 时 父类 A 和子类 B 的构造方法都会被调用到 D 实例化父类对象时 调用父类 A 的构造方法 实例化子类对象时 则只调用子类 B 的 构造方法 正确答案 D 2 该代码运行后 输出为 A A B A fun B A B B fun
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 电商内容营销自动化工具创新创业项目商业计划书
- 农畜产品天然成分提取创新创业项目商业计划书
- 农产品产地直销网络创新创业项目商业计划书
- 2025年学前教育机构师资队伍教师培训效果评价与反馈体系报告
- 2025年工业互联网平台NFV虚拟化在5G网络中的应用场景报告
- 2025年工业节能技术改造资金申请项目申报条件与评估报告
- 2025年教育行业人才流失现状与吸引力建设策略报告
- 2025年网络直播行业规范化与直播平台国际化发展商业模式创新报告
- 甘肃省定西市岷县2021-2022学年第一学期五年级科学期中试题(含答案)
- 营养师考试2025年备考实操技能与营养调查模拟试卷
- 电子商务法律风险与合规管理
- 缆索起重机检查评分
- 妊娠期并发产前子痫的处理培训课件
- 中国民族史纲要罗佑贤
- 城市道路路名牌设置、管理和维护导则
- 肝性脑病患者护理查房
- JJF(石化)053-2021间隙式湿膜制备器校准规范
- 4.3闭环控制系统的工作过程教学设计-高中通用技术必修《技术与设计2》
- 2023版设备管理体系标准
- 办公家具供货安装、保障实施及售后服务方案
- 《曼陀罗绘画疗愈-初三减压》PPT
评论
0/150
提交评论