2012java期末复习题

上传人:j****9 文档编号:45989750 上传时间:2018-06-20 格式:DOC 页数:12 大小:139KB
返回 下载 相关 举报
2012java期末复习题_第1页
第1页 / 共12页
2012java期末复习题_第2页
第2页 / 共12页
2012java期末复习题_第3页
第3页 / 共12页
2012java期末复习题_第4页
第4页 / 共12页
2012java期末复习题_第5页
第5页 / 共12页
点击查看更多>>
资源描述

《2012java期末复习题》由会员分享,可在线阅读,更多相关《2012java期末复习题(12页珍藏版)》请在金锄头文库上搜索。

1、一、单项选择题一、单项选择题 1下面哪些是 java 语言中的关键字? Asizeof Babstract CNULL DNative 2下面语句哪个是正确的? Achar=abc; Blong l=oxfff; Cfloat f=0.23;Ddouble=0.7E-3; 3以下程序测试 String 类的各种构造方法,试选出其运行效果。 class STRpublic static void main(String args)String s1=new String();String s2=new String(“String 2“);char chars=a, ,s,t,r,i,n,g;S

2、tring s3=new String(chars);String s4=new String(chars,2,6);byte bytes=0,1,2,3,4,5,6,7,8,9; StringBuffer sb=new StringBuffer(s3);String s5=new String(sb);System.out.println(“The String No.1 is “+s1);System.out.println(“The String No.2 is “+s2);System.out.println(“The String No.3 is “+s3);System.out.p

3、rintln(“The String No.4 is “+s4);System.out.println(“The String No.5 is “+s5); AThe String No.1 is The String No.2 is String 2 The String No.3 is a string The String No.4 is string The String No.5 is a string BThe String No.1 is The String No.2 is String 2 The String No.3 is a string The String No.4

4、 is tring The String No.5 is a string CThe String No.1 is The String No.2 is String 2 The String No.3 is a string The String No.4 is strin The String No.5 is a string D以上都不对 4下面语句段的输出结果是什么? int i = 9; switch (i) default: System.out.println(“default“); case 0: System.out.println(“zero“); break; case

5、1: System.out.println(“one“); case 2: System.out.println(“two“); Adefault Bdefault, zero Cerror default clause not defined Dno output displayed 5有关类 Demo,哪句描述是正确的? public class Demo extends Base private int count; public Demo() System.out.println(“A Demo object has been created“); protected void add

6、One() count+; A当创建一个 Demo 类的实例对象时,count 的值为 0。 B当创建一个 Demo 类的实例对象时,count 的值是不确定的。 C超类对象中可以包含改变 count 值的方法。 DDemo 的子类对象可以访问 count。 6当编译和运行下列程序段时,会发生什么? class Base class Sub extends Base class Sub2 extends Base public class CEx public static void main(String argv) Base b = new Base(); Sub s = (Sub) b;

7、 A通过编译和并正常运行。 B编译时出现例外。 C编译通过,运行时出现例外。 7如果任何包中的子类都能访问超类中的成员,那么应使用哪个限定词? Apublic Bprivate Cprotected Dtransient 8下面的哪个选项是正确的? class ExSuper String name; String nick_name; public ExSuper(String s,String t) name = s;nick_name = t; public String toString() return name; public class Example extends ExSup

8、er public Example(String s,String t) super(s,t); public String toString() return name +“a.k.a“+nick_name; public static void main(String args)ExSuper a = new ExSuper(“First“,“1st“);ExSuper b = new Example(“Second“,“2nd“);System.out.println(“a is“+a.toString();System.out.println(“b is“+b.toString();

9、A编译时会出现例外。 B运行结果为:a is Firstb is second C运行结果为:a is Firstb is Secong a.k.a 2nd D运行结果为:a is First a.k.a 1ndb is Second a.k.a 2nd 9运行下列程序的结果是哪个?abstract class MineBase abstract void amethod(); static int i; public class Mine extends MineBasepublic static void main(String argv)int ar = new int5;for(i =

10、 0;i 4)?99.9:9); A、输出结果为:value is 99.9 B、输出结果为:value is 99.99C、输出结果为:value is 9.0 D、编译错误 24在 Java Applet 程序用户自定义的 Applet 子类中,常常重载( )方法在 Applet 的界面中显示文字、图形和其它界面元素。 A、start( ) B、stop( ) C、init( ) D、paint( ) 25编译 Java Applet 源程序文件产生的字节码文件的扩展名为()。 A、java B、class C、html D、exe26在使用 interface 声明一个接口时,只可以使用

11、( )修饰符修饰该接口。AprivateBprotected Cprivate protectedDpublic27在编写异常处理的 Java 程序中,每个 catch 语句块都应该与( )语句块对应,使得用该语句块来启动 Java 的异常处理机制。Aif - else Bswitch Ctry Dthrow28请问所有的例外类皆继承哪一个类? A java.io.Exception Bjava.lang.Throwable C java.lang.Exception Djava.lang.Error29paint()方法使用哪种类型的参数? AGraphics BGraphics2D CSt

12、ring DColor 30指出正确的表达式 Abyte=128; BBoolean=null; Clong l=0xfffL; Ddouble=0.9239d; 31类的设计要求它的某个成员变量不能被外部类直接访问,应该使用下面的哪些修饰符获得需要的访问控制( )? Apublic Bdefault Cprotected Dprivate 32、paint()方法使用哪种类型的参数?( ) A、Graphics B、Graphics2D C、String D、Color 33、指出正确的表达式( ) A、byte=128; B、Boolean=null; C、long l=0xfffL; D

13、、double=0.9239d; 34、指出下列程序运行的结果( ) 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) str=“test ok“;

14、 ch0=g; A、good and abc B、good and gbc C、test ok and abc D、test ok and gbc 35、运行下列程序, 会产生什么结果( ) 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、第一行会产生编译错误 B、第六行会产生编译

15、错误 C、第六行会产生运行错误 D、程序会运行和启动 36、要从文件“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“); int c=in.read(); D、RandomAccessFile in=new RandomAccessFile(“file.dat“); in.skip(9); int c=in.readByte(); 37、容器被重新设置大小后,哪种布局管理器的容器中的组件大小不随容器大小的变化而改变?(

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

当前位置:首页 > 生活休闲 > 社会民生

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