JAVAOOP复习题笔试(44页).doc





《JAVAOOP复习题笔试(44页).doc》由会员分享,可在线阅读,更多相关《JAVAOOP复习题笔试(44页).doc(46页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、-JAVAOOP复习题类型:(笔试)范围:内测/月考日期:时长:1小时总分数:100 分姓名:准考证号:证件号码:理论部分注意:考试结束试卷必须交回,答案填写在答题卡上第 46 页-1. .给定两个java程序,如下:Text.java的编译运行结果是(选一项)pubilc interface Face int count = 40;pubilc class Text implements Face private static int counter; pubilc static void main(Stringargs) System.out.println( counter );A、40
2、B、41C、0D、12. Java程序中读入用户输入的一个值,要求创建一个自定义的异常,如果输入值大于10,使用throw语句显式地引发异常,异常输出信息为“somethings wrong!”,语句为(选一项)A、if (I10) throw Exception(somethings wrong!);B、if (I10) throw Exception e (somethings wrong!);C、if (I10) throw new Exception(somethings wrong!);D、if (I10) throw new Exception e (somethings wron
3、g!);3. Java程序中类的定义如下:class Demo private int count; public Demo() count=new int10; public void setCount(int ct,int n) countn=ct; public int getCount(int n) return countn; public void showCount(int n) System.out.println(Count is +countn); 在创建Demo类的实例后,通过调用showCount(9)方法得到的显示结果是(选一项)A、Count is 0B、Count
4、 is nullC、编译错误D、运行时错误4. java程序中有如下代码:DataInputStream din = new DataInputStream ( new BufferedInputStream(new FileInputStream(employee.dat) );假设在employee.dat文件中只有如下一段字符:abcdefg。则:System.out.println(din.read()在屏幕上打印(选一项)A、AB、BC、97D、985. java语言中,下列处理输出操作的所有类的基础的是(选一项)A、DataOutputB、OutputStreamC、Buffere
5、dOutputStreamD、IOStream6. Java中,使用()修饰符时,一个类能被同一包或不同包中的其他类访问。(选一项)A、privateB、protectedC、publicD、friendly7. public class MyClass1public static void main (String argv)_ class MyInner 在以上java代码中的横线上,不可放置()修饰符。(选一项)A、publicB、privateC、staticD、friend8. public class Test public static void main(String args
6、) EqTest e = new EqTest(); e.show(); class EqTest String s = Java; String s2 = java; public void show() /在这儿放置测试代码 System.out.println(相等); else System.out.println(不相等); 在上面的Java代码的注释行位置,放置()测试代码能输出“相等”结果。(选一项)A、if(s=s2)B、if(s.equals(s2)C、if(s.equalsIgnoreCase(s2)D、if(s.noCaseMatch(s2)9. 包pack1的类clas
7、s1中有成员方法:protected void method_1(),private void method_2(),public void method_3()和void method_4(),在包pack2中的类class2是class1的子类,你在class2中可以调用方法(选两项)A、method_1B、method_2C、method_3D、method_410. 编译并运行下面的Java程序:class A int var1=1; int var2; public static void main(String args) int var3=3; A a = new A(); Sy
8、stem.out.println(a.var1+a.var2+var3); 将产生( )结果。(选一项)A、0B、4C、3D、代码无法编译,因为var2根本没有被初始化11. 编译并运行下面的Java代码段char c = a;switch (c) case a: System.out.println(a); default: System.out.println(default); 输出结果是(选一项)A、代码无法编译,因为switch语句没有一个合法的表达式B、a defaultC、aD、default12. 分析下列Java代码:class A public static void ma
9、in(String args) method(); static void method() try System.out.println(Hello); finally System.out.println(good-bye); 编译运行后,输出结果是(选一项)A、“Hello”B、“good-bye”C、“Hello good-bye”D、代码不能编译13. 分析下面的Java程序:public class ExceptionTest public static void main(String args) throws Exception try throw new Exception(
10、); catch(Exception e) System.out.println(Caught in main(); System.out.println(nothing); 输出结果为(选一项)A、Caught in main()nothingB、Caught in main()C、nothingD、没有任何输出14. 给定 Java 代码如下 , 要打印出list中存储的内容,以下语句正确的是(选两项)ArrayList list= new ArrayList();list.add(a);list.add(b);A、System.out.print(list);B、System.out.p
11、rint(list.toArray();C、System.out.print(list.toString();D、System-out-print(list.get(0);15. 给定Java代码,如下:abstract class Shape abstract void draw();要创建Shape类的子类Circle,以下代码正确的是(选两项)A、class Circle extends Shapeint draw()B、abstract class Circle extends Shape C、class Circle extends Shapevoid draw();D、class
12、Circle extends Shapevoid draw();16. 给定java代码,如下:编译运行,结果是(选一项)public static void main(String args) String s; System.out.println( s= + s);A、编译错误B、编译通过,但出现运行时错误C、正常运行,输出s=nullD、正常运行,输出s=17. 给定java代码,如下:运行时,会产生()类型的异常。(选一项)String s = null;s.concat(abc);A、AritthmeticExceptionB、NullpointerExceptionC、IOExc
13、eptionD、EOFException18. 给定java代码片段,如下:Integer a = new Integer(3);Integer b = new Integer(3);System.out.println(a=b);运行后,这段代码将输出(选一项)A、1B、0C、trueD、false19. 给定java代码如下,d的取值范围是(选一项)double d = Math.random();A、d=1.0B、d=0.0,并且d=0.0,并且d=1.0,并且dDouble.MAX_VALUE20. 给定Java代码如下,运行时,会产生( )类型的异常。(选一项)String s =
14、null;s.concat(abc);A、ArithmeticExceptionB、NullPointerExceptionC、IOExceptionD、EOFException21. 给定某Java程序的main方法如下,该程序编译运行的结果是(选一项)public static void main(Stringargs) String str = null; str.concat(abc); str.concat(def); System.out.println(str);A、nullB、abcdefC、编译错误D、运行时出现异常22. 给定如下JAVA 程序片断:class A publ
15、ic A() system.out.println(A); class B extends A public B() System.out.println(B); public static void main(String args) B b = new B(); 上述程序将(选一项)A、不能通过编译B、通过编译,输出为: A BC、通过编译,输出为: BD、通过编译,输出为: A23. 给定如下Java代码,编译时会在( )出现错误。(选一项)class Parent class Child extends Parent public static void main(String arg
16、s) Parent p1 = new Child();/第一行 Parent p2 = new Parent();/第二行 Child c1 = new Child();/第三行 Child c2 = new Parent();/第四行 A、第一行B、第二行C、第三行D、第四行24. 给定如下Java代码,编译运行时,以下( )语句的值是true。(选两项)String s = hello;String t = hello;String e = new String(hello);char c = h,e,l,l,o;A、s.equals( t )B、t.equals( c )C、t.equa
17、ls( e )D、t=c25. 给定一个Java程序代码,如下:运行编译后,输出结果是(选一项)pubilc class Test int count = 9; pubilc void count1() int count = 10; System.out.println(count1 + count); pubilc void count2() System.out.println(count2 + count); pubilc static void main(String args) Test t = new Twst(); t.count1(); t.count2(); A、count
18、1=9 count2=9B、count1=10 count2=9C、count1=10 count2=10D、count1=9 count2=1026. 给定一个Java程序的代码片断如下,运行后,正确的输出结果是(选一项)String s=hello,world;s.replace(, );System.out.println(s);A、hello world;B、hello, worldC、HELLO WORLD;D、HELLO ,WORLD;27. 给定一个java程序的方法结构,如下:public Integer change(String s)以下方法体实现语句正确的是(选两项)A、
19、return new Integer(s);B、return s;C、Integer t = Integer.valueOf(s);return t;D、return s.getInteger();28. 接口的定义如下:interface A int method1(int i); int method2(int j);类B实现了接口A,以下( )是正确的。(选一项)A、class B implements A int method1() int method2() B、class B int method1(int i) int method2(int j) C、class B imple
20、ments A int method1(int i) int method2(int j) D、class B extends A int method1(int i) int method2(int j) 29. 类 Java.util.HashMap 实现了( )接口。(选一项)A、collectionB、SetC、MapD、List30. 如下Java代码段,体现了()概念。(选一项)public void aMethod(String s).public void aMethod(int i).public void aMethod(int i,float f).A、多继承B、重载C、
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- JAVAOOP 复习题 笔试 44

限制150内