《Java面向对象》笔试3套_2570

上传人:ba****u 文档编号:52671321 上传时间:2022-02-08 格式:DOCX 页数:15 大小:38.57KB
收藏 版权申诉 举报 下载
《Java面向对象》笔试3套_2570_第1页
第1页 / 共15页
《Java面向对象》笔试3套_2570_第2页
第2页 / 共15页
《Java面向对象》笔试3套_2570_第3页
第3页 / 共15页
资源描述:

《《Java面向对象》笔试3套_2570》由会员分享,可在线阅读,更多相关《《Java面向对象》笔试3套_2570(15页珍藏版)》请在装配图网上搜索。

1、 Java 面向对象编程选择题(单选 50 题)1. 欲构造 ArrayList类的一个实例,此类继承了A、 ArrayList myList=new Object();B、 List myList=new ArrayList();C、 ArrayList myList=new List();D、 List myList=new List();List接口,下列哪个方法是正确的?2.paint()方法使用哪种类型的参数?A、 GraphicsB、 Graphics2DC、 StringD、 Color3. 指出正确的表达式A、 byte=128;B、 Boolean=null;C、 long

2、l=0xfffL;D、 double=0.9239d;4. 指出下列程序运行的结果public class ExampleString str=new String(good);charch=a,b,c;public static void main(String args)Example ex=new Example();ex.change(ex.str,ex.ch);System.out.print(ex.str+ and );Sytem.out.print(ex.ch);public void change(String str,char ch)str=test ok;ch0=g;A、

3、good and abcB、 good and gbcC、 test ok and abcD、 test ok and gbc5. 运行下列程序 , 会产生什么结果public class X extends Thread implements Runnablepublic void run()System.out.println(this is run();public static void main(String args)Thread t=new Thread(new X();t.start();A、 第一行会产生编译错误B、 第六行会产生编译错误C、 第六行会产生运行错误D、 程序会

4、运行和启动6. 要从文件 file.dat 文件中读出第 10 个字节到变量 C中 , 下列哪个方法适合 ? A、 FileInputStream in=new FileInputStream(file.dat); in.skip(9); intc=in.read();B、 FileInputStream in=new FileInputStream(file.dat); in.skip(10); intc=in.read();C、 FileInputStream in=new FileInputStream(file.dat); int c=in.read();D、 RandomAccess

5、File in=new RandomAccessFile(file.dat); in.skip(9); int c=in.readByte();7. 容器被重新设置大小后,哪种布局管理器的容器中的组件大小不随容器大小的变化而改变?A、 CardLayoutB、 FlowLayoutC、 BorderLayoutD、 GridLayout8. 给出下面代码:public class Personstatic int arr = new int10;public static void main(String a)System.out.println(arr1);那个语句是正确的?A、 编译时将产

6、生错误;B、 编译时正确,运行时将产生错误;C 、输出零;D、 输出空。9. 哪个关键字可以对对象加互斥锁?A、 transientB synchronizedC serializeD static10. 下列哪些语句关于内存回收的说明是正确的?A、 程序员必须创建一个线程来释放内存;B、 内存回收程序负责释放无用内存C、内存回收程序允许程序员直接释放内存D、内存回收程序可以在指定的时间释放内存对象11. 下列代码哪几行会出错 : 1) public void modify() 2) int I, j, k;3) I = 100;4) while ( I 0 ) 5) j = I * 2;6)

7、 System.out.println ( The value of j is + j );7) k = k + 1;8) I-;9) 10 A、 line 4B、 line 6C、 line 7D、 line 812.MAX_LENGTH是 int型 public成员变量 ,变量值保持为常量100,用简短语句定义这个变量。A、 public int MAX_LENGTH=100;B、 final int MAX_LENGTH=100;C、 final public int MAX_LENGTH=100;D、 public final int MAX_LENGTH=100.13. 给出下面代码

8、:1) class Parent 2 private String name;3 public Parent()4 5) public class Child extends Parent 6 private String department;7 public Child() 8 public String getValue() return name; 9 public static void main(String arg) 10 Parent p = new Parent();11 12 那些行将引起错误?A、第3行B、第6行C、第7行D、第8行14. 类 Teacher 和 Stud

9、ent 是类 Person 的子类; Person p;Teacher t; Student s;/p, t and s are all non-null.if(t instanceof Person) s = (Student)t; 最后一句语句的结果是:A、 将构造一个Student 对象;B、 表达式是合法的;C、 表达式是错误的;D、 编译时正确,但运行时错误。15. 给出下面代码段1) public class Test 2) int m, n;3) public Test() 4) public Test(int a) m=a; 5) public static void main

10、(String arg) 6) Test t1,t2;7) int j,k;8) j=0; k=0;9) t1=new Test();10) t2=new Test(j,k);11) 12) 哪行将引起一个编译时错误?A、 line 3B、 line 5C、 line 6D、 line 1016. 对于下列代码:1) class Person 2) public void printValue(int i, int j) /. 3) public void printValue(int i)/. 4) 5) public class Teacher extends Person 6) publ

11、ic void printValue() /. 7) public void printValue(int i) /.8) public static void main(String args)9) Person t = new Teacher();10) t.printValue(10);11) 第 10 行语句将调用哪行语句? ? A、 line 2B、 line 3 C、 line 6 D、 line 717. 哪个关键字可以抛出异常?A、 transientB、 finallyC、 throwD、 static18.下面关于构造函数的说法不正确的是()A、构造函数也属于类的方法,用于

12、创建对象的时候给成员变量赋值。B、构造函数不可以重载。C、构造函数没有返回值。D、构造函数一定要和类名相同。19.System 类在哪个包中?A、 java.utilB、 java.ioC、 java.awtD、 java.lang20. 对于下列代码: public class Parent public int addValue( int a, int b) int s;s = a+b;return s;class Child extends Parent 下述哪些方法可以加入类Child?A、 int addValue( int a, int b )/ do something.B、 p

13、ublic void addValue (int a, int b )/ do something.C、 public int addValue( int a )/ do something.D、 public int addValue( int a, int b )throws MyException /do something.21. 给出下面代码:public class teststatic int a = new a10;public static void main(String args) System.out.println(arr10);那个选项是正确的?A、 编译时将产生错

14、误;B、 编译时正确,运行时将产生错误;C、 输出零;D、 输出空。22. 下面哪些选项是正确的main 方法说明?A、 public main(String args)B、 public static void main(String args)C、 private static void main(String args)D、 void main()23. 给定下面的代码片段:1) String str = null;2) if (str != null) & (str.length() 10) 3) System.out.println(more than 10);4) 5) else

15、if (str != null) & (str.length() 5) 6) System.out.println(less than 5);7) 8) else System.out.println(end); 哪些行会导致错误?A、 line 1B、line 2C、 line 5D、 line 824. 下面属于Java线程同步方法的方法有( )A.joiny()C.wait()B.run()D.destroy()25.欲编写如下图的一个界面,用于显示用户指定的图像:如果在区域A 中只能放置一个AWT组件,从各组件的本来功能角度考虑,最好使用哪种组件:A、 TextAreaB、 Panel

16、C、 TextFieldD、 Canvas26.界面如上题所示。如果在A 区域使用某种AWT组件( java.awt.Component负责绘制图像 , 则绘图的语句最好应放在该组件的哪个方法中( 考虑到应用程序和机的 AWT线程都会要求重画该组件)?A、 构造方法B、 paint( Graphics g)C、 update ( Graphics g)D、 repaint()的子类)来Java 虚拟27. 下列哪个方法可用于创建一个可运行的类( )A.public class X implements Runable public void run(). B.public class X im

17、plements Thread public void run(). C.public class X implements Thread public int run(). D.public class X implements Runable protected void run(). 28. 如果希望所有的控件在界面上均匀排列,应使用下列哪种布局管理器()A BoxLayoutB GridLayoutC BorderLayoutD FlowLayout29. 看下面一段程序:class Aclassvoid go()System.out.println(Aclass);public cl

18、ass Bclass extends Aclassvoid goSystem.out.println(Bclass);public static void main(String args)Aclass a=new Aclass();Aclass a1=new Bclass();a.go();a1.go();以上程序运行结果是:A、 AclassAclassB、 BclassBclassC、 AclassBclassD、 BclassAclass30. 下列关于 Java 线程的说法那些是正确的()A、 每一个 Java 线程可以看成由代码、一个真实的CPU以及数据三部份组成。B、 创建线程的

19、两种方法中,从Thread 类中继承的创建方式可以防止出现多父类问题。C、 Thread 类属于 java.util程序包。D、 以上说法无一正确。31. 看以下程序: boolean a=false; boolean b=true;boolean c=(a&b)&(!b);int result=c=false?1:2;这段程序执行完后,c 与result的值是:A、 c=false;result=1;B、 c=true;result=2;C、 c=true;result=1;D、 c=false;result=2;32. 运行下列程序 , 会产生什么结果public class X exte

20、nds Thread implements Runablepublic void run()System.out.println(this is run();public static void main(String args)Thread t=newt.start();Thread(new X();A、 in the Inner outerB、 outerC、 in the InnerD、编译不通过33. 指出下列程序的运行结果int i = 9;switch (i) default:System.out.println(default);case 0:System.out.println

21、(zero);break;case 1:System.out.println(one);case 2:System.out.println(two);A、 defaultB、 default, zeroC、 error default clause not definedD、 no output displayed那个34. 运行下列程序,会产生什么结果: class Outer1private int a;void foo(double d,final float f) String s;final boolean b;class Innervoid methodInner()System.

22、out.println(in the Inner);public static void main(String args)Outer1 me=new Outer1();me.foo(123,123);System.out.println(outer);A、 in the Inner outerB、 outerC、 in the InnerD、 编译不通过35. 运行下列程序的结果是 ( ) abstract class MineBase abstract void amethod(); static int i;public class Mine extends MineBasepublic

23、 static void main(String argvint ar=new int 5 ;for(i=0;i System.out.println(ari ) );A.打印 5个0C.编译出错,Mine应声明为abstractB. 编译出错,数组ar 必须初始化D. 出现 IndexOutOfBoundes的例外36. 要从文件 file.dat文件中读出第10 个字节到变量C 中,下列哪个方法适合( )A.FileInputStreamin=newFileInputStream(file.dat);in.skip9.;intc=in.read();B.FileInputStreamin=

24、newFileInputStream(file.dat);in.skip10.;intc=in.read();C.FileInputStream in=new FileInputStream(file.dat );int c=in.read();D.RandomAccssFilein=RandomAccssFile( file.dat);in.skip9.;intc=in.readByte();37. 构造方法何时被调用 ( )A. 类定义时C.调用对象方法时B. 创建对象时D. 使用对象的变量时38.下面哪个修饰符修饰的方法只能被本类中的其他方法使用(A、 protectedB、 stati

25、cC、 private)D、public39. 为实现多线程之间的通信,需要使用下列哪种流才合适()A Filter streamB File streamC Random access streamD Piped stream40. 欲构造 ArrayList类的一个实例,此类继承了A、 ArrayList myList=new Object();B、 List myList=new ArrayList();C、 ArrayList myList=new List();D、 List myList=new List();List接口,下列哪个方法是正确的?41. 运行下列程序 , 会产生什么

26、结果public class X extends Thread implements Runablepublic void run()System.out.println(this is run();public static void main(String args)Thread t=new Thread(new X();t.start();A、 第一行会产生编译错误B、 第六行会产生编译错误C、 第六行会产生运行错误D、 程序会运行和启动42.下面哪条语句定义了5 个元素的数组()A、 int a=22,23,24,25,12;B、 int a =new int(5);C、 int 5

27、array;D、 int arr;43、数组中可以包含什么类型的元素?A、 int 型 B 、 string 型 C 、 数组_。D、 以上都可以44.给出一段程序,选择运行结果(public class sss public static void main(String args))String s1=args1;String s2=args2;String s3=args3;String s4=args4;System.out.println(“ args2=” +s2);命令行执行:A、 args2=2java sss 1 2 3 4结果是下面哪一个?B、 args2=nullC、 a

28、rgs2=1D、运行出现异常45. 类 Teacher 和 Student 是类 Person 的子类; Person p;Teacher t; Student s;/p, t and s are all non-null.if(t instanceof Person) s = (Student)t; 最后一句语句的结果是:A、 将构造一个Student 对象;B、 表达式是合法的;C、 表达式是错误的;D、 编译时正确,但运行时错误。46.给出一段程序,试判断哪个是正确的结果(public class rtExceptpublic static void throwit()System.ou

29、t.print(“ throwit” );throw new RuntimeException(); public static void main(String aa)try)System.out.print(“ hello“ );throwit(); catch(Exception re)System.out.print(“ caught” ); finallySystem.out.print(“ finally” ); System.out.print(“ after” );A、 hello throwit caughtB、 hello throwit caught finally af

30、terC、 hello throwit RuntimeException afterD、 hello throwit caught finally after RuntimeException47、以下哪个方法用于定义线程的执行体?A 、 start()B 、 init()C、 run()D、 main()48. 给出下面代码:1) class Parent 2 private String name;3 public Parent()4 5) public class Child extends Parent 6 private String department;7 public Chil

31、d() 8 public String getValue() return name; 9 public static void main(String arg) 10 Parent p = new Parent();11 12 那些行将引起错误?A、第3行B、第6行C、第7行D、第8行49.给出一段程序,试判断哪个是正确的结果(public class myprogrampublic static void main (String args)trySystem.out.print(“ Hello world” ); finallySystem.out.println(“ Finally e

32、xecuting” );)A、无法编译,因为没有指定异常B、无法编译,因为没有catch子句C、 Hello worldD、 Hello world Finally executing50.给出下面一段程序,选择运行结果()public class Xpublic static void main(String args)String names=new String5;for(int x=0;xargs.length;x+) namesx=argsx;System.out.println(names2);命令行执行:A、 namesjava X a bB、 b结果是下面哪一个?C、 nullD、 运行出现异常

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

copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!