Java练习题(选择题)_第1页
Java练习题(选择题)_第2页
Java练习题(选择题)_第3页
Java练习题(选择题)_第4页
Java练习题(选择题)_第5页
已阅读5页,还剩1页未读 继续免费阅读

下载本文档

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

文档简介

选择题 1 选择题内容 下面各选项可以在 A 的子类中使用的是 class A protected int method int a int b return 0 选项 A A public int method int a int b return 0 选项 B B private int method int a int b return 0 选项 C C private int method int a long b return 0 选项 F D public short method int a int b return 0 答案 A C 选择题 2 选择题内容 下列代码执行的结果是 class Base void test System out println Base test public class Child extends Base void test System out println Child test public static void main String a Child anObj new Child Base baseObj anObj baseObj test 选项 A A Child test Base test 选项 B B Base test Child test 选项 C C Base test 选项 F D Child test 答案 D 选择题 3 选择题内容 关于以下程序代码的说明正确的是 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 A 5 行不能通过编译 因为引用了私有静态变量 选项 B B 10 行不能通过编译 因为 x 是私有静态变量 选项 C C 程序通过编译 输出结果为 x 103 选项 F D 程序通过编译 输出结果为 x 102 答案 D 选择题 4 选择题内容 关于 java lang String 类 以下描述正确的一项是 选项 A A String 类是 final 类故不可以继承 选项 B B String 类是 final 类故可以继承 选项 C C String 类不是 final 类故不可以继承 选项 F D String 类不是 final 类故可以继承 答案 A 选择题 5 选择题内容 下列关于 interface 的说法正确的是 选项 A A interface 中可以有 private 方法 选项 B B interface 中可以有 final 方法 选项 C C interface 中可以有方法实现 选项 F D interface 可以继承其他 interface 答案 D 选择题 6 选择题内容 以下程序正确的输出是 public class FatherClass public FatherClass System out println FatherClass Create public class ChildClass extends FatherClass public ChildClass System out println ChildClass Create public static void main String args FatherClass fc new FatherClass ChildClass cc new ChildClass 选项 A A FatherClass Create FatherClass Create ChildClass Create 选项 B B FatherClass Create ChildClass Create FatherClass Create 选项 C C ChildClass Create ChildClass Create FatherClass Create 选项 F D ChildClass Create FatherClass Create FatherClass Create 答案 A 选择题 7 选择题内容 请看如下代码 class Person private int a public int change int m return m public class Teacher extends Person public int b public static void main String arg Person p new Person Teacher t new Teacher int i point x 下面哪些放在 point x 行是正确的 选项 A A i b 选项 B B i p a 选项 C C i p change 30 选项 F D i t b 答案 C D 选择题 8 选择题内容 下列选项中放置于 插入代码 处会编译出错的是 interface IFace class CFace implements IFace class Base public class ObRef extends Base public static void main String argv ObRef ob new ObRef Base b new Base Object o1 new Object IFace o2 new CFace 插入代码 选项 A A o1 o2 选项 B B b ob 选项 C C ob b 选项 F D o1 b 答案 C 选择题 9 选择题内容 已知类 Student 的定义如下 public class Student String name Student String name this name name 插入代码 main 方法代码 Student stu1 new Student new String tom Student stu2 new Student tom System out print stu1 stu2 System out println stu1 equals stu2 如果控制台的输出结果是 false true 那么 插入代码 处填入的代码正确的是 选项 A A public boolean equals Object obj if obj instanceof Student Student stu Student obj return stu name this name else return false 选项 B B public boolean equals Object obj if obj instanceof Student Student stu Student obj return stu name equals this name else return false 选项 C C public boolean equals Object obj if obj instanceof Student return obj name equals this name else return false 选项 F D public boolean equals Object obj if obj instanceof Student return obj name this name else return false 答案 B 选择题 10 选择题内容 指出下列程序运行的结果 public class Example String str new String good char ch a b c public static void main String args Example ex new Example ex change ex str ex ch System out print

温馨提示

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

评论

0/150

提交评论