抽象方法必须在抽象类中_第1页
抽象方法必须在抽象类中_第2页
抽象方法必须在抽象类中_第3页
抽象方法必须在抽象类中_第4页
抽象方法必须在抽象类中_第5页
已阅读5页,还剩16页未读 继续免费阅读

下载本文档

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

文档简介

一 一 判断题判断题 1 抽象方法必须在抽象类中 所以抽象类中的方法都必须是抽象方法 2 Final 类中的属性和方法都必须被 final 修饰符修饰 3 最终类不能派生子类 最终方法不能被覆盖 4 子类要调用父类的方法 必须使用 super 关键字 5 一个 Java 类可以有多个父类 6 如果 p 是父类 Parent 的对象 而 c 是子类 Child 的对象 则语句 c p 是正确的 7 一个类如果实现了某个接口 那么它必须重载该接口中的所有方法 8 接口是特殊的类 所以接口也可以继承 子接口将继承父接口的所有常量和抽象方法 9 子类的域和方法的数目一定大于等于父类的域和方法的数目 10 所谓静态初始化器就是在构造函数之前加上 static 修饰符 11 在 java 中 一个类可同时定义许多同名的方法 这些方法 这些方法的形式参数的 个数 类型或顺序各不相同 这种面向对象程序特性称为隐藏 12 一个类只能有一个父类 但一个接口可以有一个以上的父接口 13 抽象类没有具体对象 所以抽象类没有构造函数 14 接口是特殊的类 所以接口也可以继承 予接口将继承父借口的所有常量和抽象方法 15 Java 语言不支持类的多重继承 16 一个类就相当于一种数据类型 17 类的定义是可以嵌套的 18 方法重载要求方法名相同 参数列表也相同 19 方法覆盖要求子类的方法与被覆盖的方法的方法头完全一致 范围一致或变小 多选题 每题两个正确答案 1 在 Java 中 下列哪两句是正确的 cd A 子类的构造方法与父类的构造方法同名 B 子类可以继承父类的所有方法 C 子类不一定能继承父类的所有方法 D 子类可以继承父类 protected 和 public 的方法 E 子类可以继承父类 protected 和 private 的方法 2 MyPoint 方法 返回 Point 类型 其定义正确的是 ac A public Point MyPoint int x B public int MyPoint int x C static Point MyPoint int x int y D static int MyPoint Point p 3 若有以下接口的定义 public interface IA extends IB IC ID 则 bd A 这个接口的声明是错误的 B 接口 IA 继承了接口 IB IC 和 ID C 接口 IA 实现了接口 IB IC 和 ID D 关键字 extends 指明接口的继承关系 4 下面哪几个函数是 public void example 的重载函数 ad A public void example int m B public int example C public void example2 D public int example int m float f 5 已知如下定义 String s story 下面哪个表达式是合法的 ad A s books B char c s 1 C int len s length D String t s toLowerCase 6 定义主类的类头时可以使用到的关键字是 ab A abstract B final C private D super 一 单选题 共 12 题 每题 2 分 共 24 分 1 程序设计语言的三种基本控制结构是 B A 输入 处理 输出 B 顺序 选择 循环 C 树形 网形 环形 D 主程序 子程序 函数 2 在 Java 中 下列哪句话是正确的 A A 几个类可以写在一个文件里 B 一个类可以写在几个文件里 C 类的名称是不区分大 小写的 D 方法的名称是不区分大 小写的 3 一个必须被继承的类要用哪个关键字来描述 D A static B protected C final D abstract 4 下面程序的输出结果是 D class DemoClass public static void main String args int i 1 s 5 do s i i while i 0 x length 0 11 编译运行以下程序后 关于输出结果的说明正确的是 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 99B 输出结果为 value is 9 C 输出结果为 value is 9 0D 编译错误 12 以下声明合法的是 A default String s B public final static native int w C abstract double d D abstract final double hyperbolicCosine 13 关于以下 application 的说明 正确的是 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 14 关于以下程序代码的说明正确的是 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 15 以下选项中循环结构合法的是 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 j5 System out println value is s 3 以下程序段的输出结果为 int x 0 y 4 z 5 if x 2 if y5 System out println Message three else System out println Message four 4 以下程序段的输出结果为 int j 2 switch j case 2 System out print Value is two case 2 1 System out println Value is three break default System out println value is j break 5 阅读以下程序段 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 输出结果为 6 以下程序段的输出结果为 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 7 已有 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 8 以下程序段的输出结果为 class Cruncher void crunch int i System out println int version void crunch String s System out println String version public static void main String args Cruncher crun new Cruncher char ch p crun crunch ch 第二页第二页 1 所谓静态初始化器就是在构造函数之前加上 static 修饰符 2 java application 是同独立解释器程序来运行的 3 java 的字符类型彩是 Unicode 编码 每个 unicode 码占 8 个比特 4 子类的域和方法的数目一定天于等于父类的域和方法和数目 5 构造函数是类的一种特殊函 它的方法名必须与类名相同 它的返回类型只能是 void 6 Vector 类中的对象不能是简单数据类型 7 java 中的 String 类的对象既可以是字符串常量 也可以是字符串变量 8 在 java 中 一个类可同时定义许多同名的方法 这些方法 这些方法的形式参数的个数 类型或顺序各不相同 这种面向对象程序特性称为隐藏 9 java 中并非每个事件类都只对应一个事件 10 一个类只能有一个父类 但一个接口可以有一个以上的父接口 11 抽象类没有具体对象 所以抽象类没有构造函数 12 子类要调用父类的方法 必须使用 super 关键字 13 如果 P 是父类 PARENT 的对象而 C 是子类 Child 的对象 则语句 c p 是正确的 14 当一个方法在运行过程中产生一个异常 则这个方法会终止 但是整个程序不一定终止 运行 15 一个线种对象的具体操作是同 run 方法的内容确定的 但是 Thread 类的 run 方法是 空的 其中没有内容 所以用户程序要么派生一个 Thread 的子类并在子类里重新定义 run 方 法 要么使一个类实现 Rnnnable 接口并书定写其中 run 方法的方法体 1 以下哪个代码段可以成功通过编译并在运行时打印出 yes A int x 100 Integer y new Integer 100 if x y sysytem out println yes B int x 100 float y 100 0f if x y sysytem out println yes C integer x new Integer 100 integer y new Integer 100 int x 100 Integer y new Integer 100 if x y sysytem out println yes D String x new String 100 String y new String 100 int x 100 Integer y new Integer 100 if x y sysytem out println yes 2 在使用 inter face 声明一个接口时只可以用 修饰符修饰该接口 A private B protected C public D private protected 3 设有下面两个赋值语句 以下说法正确的是 a integer parseInt 1024 B integer valueof 1024 intVAlue A a 是整数类型变量 b 是整数类对象 B a 是整数类对象 b 是整数类型变量 C A 和 B 都是整数类对象并且值相等 D a 和 b 都是整数类型变量并且它们的值相等 4 以下标识符中哪项是不合法的 A MeaninglessName B int C 1 D 2ND 5 main 方法是 Java Application 程序招待的入口点 关于 main 方法的方法头以下哪项是佥的 A public static void main B public static void main String args C public static int main String arg D public void main String arg 6 以下哪个表达式是不合法的 A string x JAVA int y 1 x y B string x JAVA int y 1 if x y C string x JAVA int y 1 x y x D string x null int y x null 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 HasStatic x 10 system out printin x x 11 12 A 第五行不能通过编译 因为引用了私有表态变量 B 第 9 行不能通过编译 因为 X 是私有表态变量 C 程序通过编译 输出结果为 X 103 D 程序通过编译 输出结果为 X 104 10 如下代码段执行后 一种可能的结果是 1 outer for int i 0 i 2 i 2 for int j 0 j 3 j 3 if i j 4 continue outer 5 System out printin i i j j 6 A i 0 j 0 B i 0 j 1 C i 1 j 0 D i 1 j 2 11 类 Test1 定义如下 1 public class Test1 2 public float aMethod float a float b 3 4 将以下哪种方法插入行 3 是不会法的 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 public float aMethod int a int b int c 12 关于以下代段的说法正确的是 1 String s abcde 2 StringBuffer s1 new StringBuffer abcde 3 if s equals s1 4 s1 null 5 if s1 equals s 6 s null A 第一行编译错误 String 的构造器必须明确调用 B 第三行编译错误 因为 S 和 S1 有不同的类型 C 编译成功 但执行时在第五行有异常抛出 D 编译成功 过程中也没有异常抛出 13 以下说法哪项是正确的 1 class MyListenet 2 extends MouseAdapter implements MouseListener 3 public void mouseEnered MouseEvent mev 4 System out printin Mouse entered 5 A 以上代码可通过编译 B 不能通过编译 因为没有实现 MouseListener 接口中的所有方法 C 不能通过编译 因为类头定义不能分行 D 能通过编译 若组件用该类作为 Mouse 的监听者并且接收了 Mouse exited 事件 则在执行 过程中会抛出异常 14 设有下面两类的定义 class Pperson long id String name class Student extends Person int score intgeScorre return score 问 类 Person 和类 Student 的关系是 A 包含关系 B 无关系 上述类定义有语法错误 C 关联关系 D 继承关系 15 一个线程的 run 方法包含以下的语句 1 try 2 sleep 100 3 cetch intrruptedException e 假定该线程没有被打断 以下哪个说法是正确的 A 代码不能通过编译 因为 run 方法中的意外不能被捕获 B 在第 2 行 线程会暂停运行 最多不超过 100 毫秒继续运行 C 在第 2 行 线程会暂停运行 恰好在 100 毫秒后继续运行 D 在第 2 行 线程会暂停运行 在 100 毫秒后的某一时候继续运行 三 改过题 每题 3 分 共 15 分 判断下面的程序片段是否正确 若有错 说明错在哪里并改 正 若正确 打 1 public class MyMain public static void main String args System out println MyClass1 data class MyClass1 int data 10 2 interface Myinterface void method1 abstract class Parent implements MyInterface class Child extends Parent void method1 system out println I am implemented now 3 public static void main String args try char ch char System in read 其他语句 catch Exception e rreturn catch Ioewception e Sysstem out println e to String 4 class AmlWrong int data1 data2 AmlWrong data2 d this 5 class parent private int mine calss child extends parent int get Mine return mine 四 程序阅读 1 以下程序的输出结果为 Public class EpualsMethod public static void main string args Integer n1 new Integer 123 Integer n2 new Integer 123 System out print n1 n2 2 假设已有以下的类定义 package abcde public class Bird protected static int referenceCount 0 public Bird referenceCount 2 protected void fly static int getRefCount return regerenceCount 请写出以下程序的输出结果 Package singer Class Nightingale extends abcde Bird Nightingale referenceCount Public static void main String args System out print Before referenceCount Nightingale Florence new Nighfingale System out println After referenceCount Florence fly 3 阅读以下程序 写出输出结果 Class Q3 Public static void main String args Holder h new Holder h held 100 h bump h System out printin h held calss Holder public int held public void bump Holder theHolder theHolder held 4 以下程序的输出结果为 Class IntOrString Void iors int i System out println int version Void iors String s System out println String version Public static void main String args IntOrString whichone new IntOrString Char c h Whichone iors ch 5 阅读以下程序段 假定服务器端和客户端程序正常运行无异常发生 请回答以下问题 1 服务器程序的端口号是 服务器的 IP 地址是 2 客户端的输出结果是 服务器端程序 import java io import public class MyServer public static final int PORT 8080 public static void main string args throws IOException try ServerSockets new ServerSockets PORT While true Socket socket s accept PrintWriter out new PrintWriter new B

温馨提示

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

评论

0/150

提交评论