1、JAVA程序设计复习题JAVA程序设计复习题一、单项选择题1在基于UDP的通信方式下,实现接收数据包的类是ASocket类 BServerSocket类 CDatagramPacket类 DDatagramSocket类2下面哪些是java语言中的关键字? Asizeof Babstract CNULL DNative3paint()方法使用的参数是AGraphics BGraphics2D CString DColor 4下面语句哪个是正确的? Achar=abc; Blong l=oxfff; Cfloat f=0.23; Ddouble=0.7E-3;5方法的重载必须满足的条件是: A参
2、数的个数不同,或者是参数的类型不同 B参数的顺序不同C方法的名字不同 D返回类型不同6Object类所属的包是A包java.util B包java.lang C包java.system D包java.Object7通过建立Dialog 的子类来建立一个A文本框类 B列表类 C文件对话框类 D对话框类8创建新线程对象之后,进入线程的生命周期的A新建 B中断 C运行 D死亡9有关类Demo,哪句描述是正确的? public class Demo extends Base private int count; public Demo() System.out.println(A Demo objec
3、t has been created); protected void addOne() count+; A当创建一个Demo类的实例对象时,count的值为0。B当创建一个Demo类的实例对象时,count的值是不确定的。C超类对象中可以包含改变count 值的方法。DDemo的子类对象可以访问count。10Frame 类是Container 类的间接子类,可使用FrameA创建一个菜单对象 B创建一个窗口对象 C创建一个对话框对象 D创建一个文件对象11所有输出流都是. AOutputStream或Writer的子类 BOutputStream的子类CWriter的子类 DOutput的
4、子类12如果任何包中的子类都能访问超类中的成员,那么应使用哪个限定词? Apublic Bprivate Cprotected Dtransient13可以对对象加互斥锁的关键字是Atransient Bsynchronized Cserialize Dstatic14在使用interface声明一个接口时,可使用的修饰符是Aprivate Bprotected Cprivateprotected Dpublic15下面哪种注释方法能够支持javadoc命令: A/*.*/ B/*.*/ C/ D/*.*/ 16要从文件 file.dat文件中读出第10个字节到变量C中,下列哪个方法适合? A
5、FileInputStream in=new FileInputStream(file.dat); in.skip(9); int c=in.read();BFileInputStream in=new FileInputStream(file.dat); in.skip(10); int c=in.read();CFileInputStream in=new FileInputStream(file.dat); int c=in.read();DRandomAccessFile in=new RandomAccessFile(file.dat); in.skip(9); int c=in.r
6、eadByte();17请问所有的例外类皆继承哪一个类? Ajava.io.Exception Bjava.lang.Throwable Cjava.lang.Exception Djava.lang.Error18要观察一个字符在unicode 表中的顺序位置,显式转换时必须使用的数据类型是Aboolean Bint 类型 Cchar Dunicode19只有在本类中创建该类的对象时,这个对象才能访问自己的私有成员变量和类中的私有方法,应采用的修饰符是:Astatic Bprivate Cprotected Dpublic20下面程序段的执行结果是什么?public class Foo pu
7、blic static void main(String args) tryreturn; finallySystem.out.println(Finally); A程序正常运行,但不输出任何结果。B程序正常运行,并输出 Finally。C编译能通过,但运行时会出现一个例外。D因为没有catch语句块,所以不能通过编译。21编译JavaApplication 源程序文件产生的字节码文件的扩展名为( )。Ajava Bclass Chtml Dexe22java.awt 包的类Panel 是用来建立A多行文本 B标签 C面板 D文本框23GridLayout对应的布局将容器中的组件按照A将容器的
8、空间分为东、西、南、北、中五个区域,中间的区域最大B加入的先后顺序从左向右排列C划分成若干行乘若干列的网格区域,组件就位于这些划分出来的小格中D由用户定制24下列哪个是合法的Java标识符?A&2 B123.9 C_2# Dpublic25设有下面两个类的定义:classPerson longid; /身份证号Stringname; / 姓名 class StudentextendsPerson int score; / 入学总分int getScore() returnscore; 问:类Person和类Student的关系是?A包含关系 B继承关系 C关联关系 D无关系,上述类定义有语法错
9、误26在使用interface声明一个接口时,只可以使用( )修饰符修饰该接口。Aprivate Bprotected Cprivateprotected Dpublic27在编写异常处理的Java程序中,每个catch语句块都应该与( )语句块对应,使得用该语句块来启动Java的异常处理机制。Aif else Bswitch Ctry Dthrow28下列描述正确的是:A多态性就是指子类的某个方法被其父类重写时,可以各自产生自己的功能行为。B多态性就是指子类的某个方法被其父类重写时,不能各自产生自己的功能行为。C多态性就是指父类的某个方法被其子类重写时,可以各自产生自己的功能行为。D以上都不
10、对29Date 类属于Ajava.time 包 Bjava.util 包 Cjava.tool 包 Djava.system 包30请问所有的例外类皆继承哪一个类? A java.io.Exception Bjava.lang.Throwable C java.lang.Exception Djava.lang.Error31paint()方法使用哪种类型的参数? AGraphics BGraphics2D CString DColor 32指出正确的表达式 Abyte=128; BBoolean=null; Clong l=0xfffL; Ddouble=0.9239d; 33运行Java
11、Applet 的工具是:Ajavac Bjava Cjavadoc D浏览器34创建文本区的监视器的类必须要实现的接口是AItemListener BChoiceListener CTextListener DActionListener35类的设计要求它的某个成员变量不能被外部类直接访问,应该使用下面的哪些修饰符获得需要的访问控制( )?Apublic Bdefault Cprotected Dprivate36当编译和运行下列程序段时,会发生什么? class Base class Sub extends Base class Sub2 extends Base public class
12、CEx public static void main(String argv) Base b = new Base(); Sub s = (Sub) b; A通过编译和并正常运行。 B编译时出现例外。C编译通过,运行时出现例外。37下面语句段的输出结果是什么? int i = 9; switch (i) default: System.out.println(default); case 0: System.out.println(zero); break; case 1: System.out.println(one); case 2: System.out.println(two); A
13、default Bdefault, zero Cerror default clause not defined Dno output displayed38以下程序测试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;String s3=new String(chars);String s4=new String(chars,2,6);byt
14、e 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.println(The String No.4 is +s4);System.out.println(The String No.5 is
15、 +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 isThe String No.2 is String 2 The String No.3 is a string The String No.4 is tring The String No.5 is a string CThe String No.1 isThe String No.2 i
16、s String 2The String No.3 is a string The String No.4 is strin The String No.5 is a string D以上都不对39下面的哪个选项是正确的? 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 ExSuper public Exa
17、mple(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();A编译时会出现例外。B运行结果为:a is Firstb
18、 is secondC运行结果为:a is Firstb is Secong a.k.a 2ndD运行结果为:a is First a.k.a 1ndb is Second a.k.a 2nd40运行下列程序的结果是哪个?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 = 0;i 0) 8) 9) j = I * 2; 10) Sy
19、stem.out.println ( The value of j is + j ); 11) k = k + 1; 12) I-; 13) 14) 15) 24调用remove(Component c)方法可以( )容器中参数指定的组件.25访问限制修饰符,按访问权限从高到低的排列顺序是public, ( ),友好的,private.三、阅读程序或程序片断,写出运行结果1class ExSuper String name; String nick_name; public ExSuper(String s,String t) name = s;nick_name = t; public St
20、ring toString() return name; public class Example extends ExSuper 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.
21、toString();System.out.println(b is+b.toString();2class Outer1 private int a; void foo(double d,final float f) String s; final boolean b; class Inner void methodInner() System.out.println(in the Inner); public static void main(String args) Outer1 me=new Outer1(); me.foo(123,123); System.out.println(outer); 3class PassRef int x ; public static void main(String args) PassRef obj = new PassRef(); obj.x = 5; change(obj); System.out.println(obj.x); public st
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1