文档介绍:重庆足下重庆足下科技有限公司版本: -1- 测试题(笔试) Java 面向对象重庆足下科技有限公司重庆足下重庆足下科技有限公司版本: -2- 不定项选择题( 40 题, 每题 分, 总分 100 分, 测试时间 2 小时) 1) 当试图编译并运行下面程序时会出现什么结果( ) (单选) class A{ public int getNumber(int a){ return a+1; }} class B extends A{ public int getNumber(int a, char c){ return a+2; } public static void main(String[] args){ B b=new B(); ((0)); }} a) 编译错误 b) 运行错误 c)1 d)2 2) 当编译并运行下面程序时会出现什么结果() (单选) public class MyAr{ public static void main(String argv[]){ int[] i= new int[5]; (i[5]); }} a) 编译错误 b) 运行错误 c) 输出 0 d) 输出“ null ” 3) final 、 finally 、 finalize 三个关键字的区别是() ( 多选) a) final 是修饰符(关键字)可以修饰类、方法、变量 b) finally 在异常处理的时候使用,提供 finally 块来执行任何清除操作 c) finalize 是方法名,在垃圾收入集器将对象从内存中清除出去之前做必要的清理工作 d) finally 和 finalize 一样都是用异常处理的方法重庆足下重庆足下科技有限公司版本: -3- 4) 当编译并运行下面程序时会发生什么结果( ) (单选) public class Bground extends Thread{ public static void main(String argv[]){ Bground b= new Bground(); (); } public void start(){ for (int i= 0;i <10; i++){ ("Value ofi="+ i); }}} a) 编译错误,指明 run 方法没有定义 b) 运行错误,指明 run 方法没有定义 c) 编译通过并输出 0到9 d) 编译通过但无输出 5)在 Java 中, 如果父类中的某些方法不包含任何逻辑, 并且需要由子类重写, 应该使用()关键字来声明父类的这些方法。(单选) a) Final b) Static c) Abstract d)V oid 6) 当编译并运行下面程序时会发生什么结果: (单选) public class Hope{ public static void main(String argv[]){ Hope h= new Hope(); } protected Hope(){ for(int i =0; i <10; i ++){ (i); }}} a) 编译错误,构造方法不能被声明为 protected b) 运行错误,构造方法不能被声明为 protected c) 编译并运行输出 0到 10 d) 编译并运行输出 0到9 重庆足下重庆足下科技有限公司版本: -4- 7) 下列说法正确的是?( ) (多选) a) 数组有 length() 方法 b) String 有 length() 方法 c) 数组有 length 属性 d) String 有 length 属性 8) 当编译并运行下面程序时会发生什么结果? () (单选) public class Test{ public static void stringReplace(String text){ text=text +”c”;} public static void bufferReplace(StringBuffer text){ text=("c"); } public static void main(String args[]){ String textString=new String("java"); StringBuffer textBuffer=new StringBuffer("java"); s tringReplace(textString); bufferReplace(textBuffer); Sys