Java面向对象程序设计试题一

上传人:re****.1 文档编号:562023691 上传时间:2023-02-03 格式:DOC 页数:7 大小:30.01KB
返回 下载 相关 举报
Java面向对象程序设计试题一_第1页
第1页 / 共7页
Java面向对象程序设计试题一_第2页
第2页 / 共7页
Java面向对象程序设计试题一_第3页
第3页 / 共7页
Java面向对象程序设计试题一_第4页
第4页 / 共7页
Java面向对象程序设计试题一_第5页
第5页 / 共7页
点击查看更多>>
资源描述

《Java面向对象程序设计试题一》由会员分享,可在线阅读,更多相关《Java面向对象程序设计试题一(7页珍藏版)》请在金锄头文库上搜索。

1、Java面向对象程序设计试题一一、单项选择题D1、欲构造ArrayList类的一个实例,此类继承了List接口,下列哪个方法是正确的?( ) A ArrayList myList=new Object(); B List myList=new ArrayList(); C ArrayList myList=new List(); D List myList=new List(); C2、paint ( )方法使用哪种类型的参数? A Graphics B Graphics2D C String D Color D3、指出正确的表达式 ( ) A byte=128; B Boolean=null

2、; C long l=0xfffL; D double=0.9239d; 4、指出下列程序运行的结果 ( )。public class Example String 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

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

4、 B 第六行会产生编译错误 C 第六行会产生运行错误 D 程序会运行和启动 A6、要从文件 file.dat文件中读出第10个字节到变量C中,下列哪个方法适合? ( ) A FileInputStream in=new FileInputStream(file.dat); in.skip(9); int c=in.read(); B FileInputStream in=new FileInputStream(file.dat); in.skip(10); int c=in.read(); C FileInputStream in=new FileInputStream(file.dat);

5、int c=in.read(); D RandomAccessFile in=new RandomAccessFile(file.dat); in.skip(9); int c=in.readByte(); 7、容器被重新设置大小后,哪种布局管理器的容器中的组件大小不随容器大小的变化而改变? ( ) A CardLayout B FlowLayout C BorderLayout D GridLayout C8、给出下面代码: public class Person static int arr = new int10;public static void main(String a) Sys

6、tem.out.println(arr1); 那个语句是正确的? ( ) A 编译时将产生错误; B 编译时正确,运行时将产生错误; C 输出零; D 输出空。 9、哪个关键字可以对对象加互斥锁 ?( ) A transient B synchronized C serialize D static 10、下列哪些语句关于内存回收的说明是正确的? ( ) A 程序员必须创建一个线程来释放内存; B 内存回收程序负责释放无用内存 C 内存回收程序允许程序员直接释放内存 D 内存回收程序可以在指定的时间释放内存对象二、多项选择题AB1、下面哪些标识符在Java语言中是合法的?( ) A perso

7、ns$ B TwoUsers C *point D instanceof F.end-line BD2、下面哪些代码片段会产生编译错误?( ) A String s = Gone with the wind; String t = good ; String k = s + t; B String s = Gone with the wind; String t; t = s3 + one; C String s = Gone with the wind; String standard = s.toUpperCase(); D String s = home directory; Strin

8、g t = s - directory. AD3、下面哪些赋值语句是错误的?( ) A float f = 11.1; B double d = 5.3E12; C char c = r; D byte bb = 433; 4、给定下面的代码片段: public void Test() try method(); System.out.println(Hello World); catch (ArrayIndexOutOfBoundsException e) System.out.println(Exception?); catch(Exception e) System.out.printl

9、n(Exception1); finallySystem.out.println(Thank you!); 如果函数method正常运行并返回,会显示下面的哪些信息? ( ) A Hello World B Exception C Exception1 D Thank you! ACD5、下列哪些语句是正确的? ( ) A int a=new int3; B int a=1,3,2,3,4,1,2; C String s=new String2; D String s=can,I,help,you BC6、下面哪些语句能够正确地生成5个空字符串? ( ) A String a = new St

10、ring 5; for (int i = 0; i 5; ai+ = ); B String a = , , , , ; C String a 5; D String 5 a; BC7、下面关于Java代码安全的说法哪些是正确的?( ) A 程序执行过程中需要的所有类都是通过字节码校验程序装入的。 B 代码的运行是由Java运行环境中的解释器完成的。 C 在运行时,字节码要经过装入,校验之后,才能在解释器中执行。 D 在缺省的安全配置条件下,Java Applet不能访问任何本地资源。 AC8、下列方法属于java.lang.Math类的有(方法名相同即可): ( ) A random() B

11、 abs() C sqrt() D sin() CD9、下列表达式哪些是正确的:( ) A byte=340; B Boolean=1; C long l=-2; D double=0.9239d; BC10、下面的说法正确的是: ( ) A Java语言里的线程不是对象 B Applet不需要main方法 C Java语言的对象都是java.lang.Object的子类 D double是Java语言的合法标识符 三、 填空题1、执行下列代码后的结果是什么? int x,a=2,b=3,c=4; x=+a+b+c+; 2、 包包含了Collection的接口和类的API。3、main方法的声

12、明格式包括 4、下列程序中构造了一个SET并且调用其方法add(),输出结果是 。 public class A public int hashCode()return 1; public Boolean equals(Object b)return true public static void main(String args) Set set=new HashSet(); set.add(new A(); set.add(new A(); set.add(new A(); System.out.println(set.size(); 5、下列程序的运行结果是 。 class A clas

13、s Dog private String name; private int age; public int step; Dog(String s,int a)name=s;age=a;step=0;public void run(Dog fast)fast.step+;public static void main (String args)A a=new A(); Dog d=a.new Dog(Tom,3);d.step=25; d.run(d); System.out.println(d.step); 四、 编程题1、编写一个输出Hello World!的程序,用两种方式实现(Application、Applet)。 2、打印输出10行杨晖三角形 3、有下面一段Server段程序,目的是能够同时服务多个客户,客户的请求是一句话(一

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 高等教育 > 习题/试题

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号