分享
分享赚钱 收藏 举报 版权申诉 / 34

类型java期末考试题.doc

  • 上传人:HR专家
  • 文档编号:5526946
  • 上传时间:2019-03-06
  • 格式:DOC
  • 页数:34
  • 大小:145KB
  • 配套讲稿:

    如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。

    特殊限制:

    部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。

    关 键  词:
    java期末考试题.doc
    资源描述:

    1、 一、选择题(每道题只有一个正确答案,每小题2分,共30分)15道题1、关于 Java语言叙述错误的是:( C)AJava 语言具有跨平台性BJava 是一种面向对象的语言CJava 语言中的类可以多继承DJava 的垃圾收集机制自动回收程序已不再使用的对象2、以下叙述正确的是:( B)的确台 aA构造方法必须是 public方法Bmain 方法必须是 public方法CJava 应用程序的文件名可以是任意的D构造方法应该声明为 void类型3、关于 Java中数据类型叙述正确的是:( B)A、整型数据在不同平台下长度不同Bboolean 类型数据只有2个值,true 和 falseC数组属于

    2、简单数据类型DJava 中的指针类型和 C语言的一样4、设 int x=1,float y=2,则表达式 x / y 的值是:( D)A0B1C2D以上都不是5、以下语句有语法错的是:( A)Aint x=1;y=2;z=3Bfor (int x=10,y=0;x0;x+);Cwhile (x5);Dfor(; ;);6、关于类和对象的叙述正确的是:( A)AJava 的类分为两大部分:系统定义的类和用户自定义的类B类的静态属性和全局变量的概念完全一样,只是表达形式不同C类的成员至少有一个属性和一个方法D类是对象的实例化7、以下有关构造方法的说法,正确的是:( A)A一个类的构造方法可以有多个

    3、B构造方法在类定义时被调用C构造方法只能由对象中的其它方法调用D构造方法可以和类同名,也可以和类名不同8、以下有关类的继承的叙述中,正确的是:( D)A子类能直接继承父类所有的非私有属性,也可通过接口继承父类的私有属性B子类只能继承父类的方法,不能继承父类的属性C子类只能继承父类的非私有属性,不能继承父类的方法D子类不能继承父类的私有属性9、下列属于容器的组件有:( B)AJButtonBJPaneCCanvasDJTextArea10、void 的含义:( C)A方法体为空B定义的方法没有形参C定义的方法没有返回值D方法的返回值不能参加算术运算11、关于 Java中异常的叙述正确的是:( D

    4、)A异常是程序编写过程中代码的语法错误B异常是程序编写过程中代码的逻辑错误C异常出现后程序的运行马上中止D异常是可以捕获和处理的12、所有的异常类皆继承哪一个类?( C)Ajava.io.ExceptionBjava.lang.ThrowableCjava.lang.ExceptionDjava.lang.Error13、下面哪个不是 java语言中的关键字?( B)AlongBsizeofCinstanceofDconst14、为实现进程之间的通信,需要使用下列那种流才合适?(D)AData streamBFile streamCBuffered streamDPiped stream15、

    5、在复选框中移动鼠标,然后单击一选项,要捕获所选项必需实现哪个接口?(D)AActionListenerBMouseListenerCMouseMotionListernDItemListener二、填空题(每空1分,共20分)1、面向对象程序设计所具有的基本特征是:_抽象性_,_封装性_,_继承性_,_多态性_2、数组 x定义如下int x =new int32则 xlength 的值为_3_,x0.length的值为_2_。3、Java 中实现多线程一般使用两种方法,一是_继承 Thread类_,二是_实现 Runnable方法_4、Java 的图形用户界面设计中,有很多布局管理器用来摆放组

    6、件的位置,一般用到的布局管理器有(列出四种即可)_FlowLayout_,_GridLayout_,_BorderLayout_,_CardLayout_5、Applet 常用的方法是:_init()_、_run()_、_stop()_和 destroy()。三、阅读程序,写出程序的输出结果(每题5分,共20分)1、class Aprivate int privateVar;A(int _privateVar)privateVar=_privateVar;boolean isEqualTo(A anotherA)if(this.privateVar = anotherA.privateVar)

    7、return true;elsereturn false;public class Bpublic static void main(String args)A a = new A(1);A b = new A(2);System.out.println(a.isEqualTo(b);程序的输出结果为:_false_2、class A double f(double x, double y) return x * y;class B extends A double f(double x, double y) return x + y;public class Test public stat

    8、ic void main(String args) B obj = new B();System.out.println(“The program output is “ + obj.f(4, 6);程序的输出结果为:_ The program output is 10_3、public class Unchecked public static void main(String args) try method(); catch (Exception e) System.out.println(“A“); finally System.out.println(“B“);static void

    9、 method() try wrench();System.out.println(“C“); catch (ArithmeticException e) System.out.println(“D“); finally System.out.println(“E“);System.out.println(“F“);static void wrench() throw new NullPointerException();程序的输出结果为:EAB4、public class Test public static void main(String args) int x;int a = 0, 0

    10、, 0, 0, 0, 0 ;calculate(a, a5);System.out.println(“the value of a0 is “ + a0);System.out.println(“the value is a5 is “ + a5);static int calculate(int x, int y) for (int i = 1; i = y 的逻辑值分别为 和 。7、 方法是一种仅有方法头,没有具体方法体和操作实现的方法,该方法必须在抽象类之中定义。 方法是不能被当前类的子类重新定义的方法。8、创建一个名为 MyPackage 的包的语句是 ,该语句应该放在程序的位置为:

    11、。9、设有数组定义:int MyIntArray = 10 , 20 , 30 , 40 , 50 , 60 , 70; 则执行以下几个语句后的输出结果是 。int s = 0 ;for ( int i = 0 ; i = 0 ; i )System.out.print(ai+“ “);System.out.println( );3、 import java.awt.*;public class abc public static void main(String args) new FrameOut(); class FrameOut extends Frame / Frame 为系统定 B

    12、utton btn; / 义的窗框类FrameOut( ) super(“按钮“);btn = new Button(“按下我“);setLayout(new FlowLayout( );add(btn);setSize(300,200);show( );4、import java.io.*;public class abc public static void main(String args) SubClass sb = new SubClass( ); System.out.println(sb.max( );class SuperClass int a = 10 , b = 20 ;

    13、class SubClass extends SuperClass int max( ) return (ab)?a:b); 四、写出下面程序的运行结果(每小题 10 分,共 30 分)1、 import java.io.*;public class abc public static void main(String args ) AB s = new AB(“Hello!“,“I love JAVA.“);System.out.println(s.toString( );class AB String s1;String s2;AB( String str1 , String str2 )

    14、 s1 = str1; s2 = str2; public String toString( ) return s1+s2;2、 import java.io.* ;public class abcpublic static void main(String args ) int i , s = 0 ;int a = 10 , 20 , 30 , 40 , 50 , 60 , 70 , 80 , 90 ;for ( i = 0 ; i max ) max=temp;if (temp 0)?x.length:011、编译运行以下程序后,关于输出结果的说明正确的是 ( C)public class

    15、 Conditionalpublic static void main(String args)int x = 2;System.out.println(“value is “(x2)if (y5)System.out.println(“Message three”);else System.out.println(“Message four”);4、以下程序段的输出结果为 。(two.three.)int j=2;switch ( j ) case 2:System.out.print(“two.”);case 2+1 :System.out.println(“three.”);break;

    16、 default:System.out.println(“value is “+j);break;5、以下程序段的输出结果为 。(int)class Crunchervoid crunch( int i )System.out.println(“int”);void crunch(String s)System.out.println(“String”);public static void main(String args )Cruncher crun=new Cruncher ( );char ch=p;crun.crunch(ch);6、阅读以下程序,写出输出结果 。(99)class

    17、Q6public static void main(String args )Holder h=new Holder( );h.held=100;h.bump(h);System.out.println(h.held); class Holderpublic int held;public void bump(Holder theHolder)theHolder.held - -; 7、阅读以下程序,请写出输出结果 。(true)public class EqualsMethod public static void main(String args) Integer n1 = new Int

    18、eger(47);Integer n2 = new Integer(47);System.out.println(n1.equals(n2);1、 Java application 中的主类需包含 main 方法,main 方法的返回类型是什么?( D )A、int B、float C、double D、void2、 有以下方法的定义,请选择该方法的返回类型( D ) 。ReturnType method(byte x, double y)return (short)x/y*2;A、byte B、short C、int D、double3、 在编写 Java Applet 程序时,若需要对发生

    19、的事件作出响应和处理,一般需要在程序的开头写上( D )语句。A、import java.awt.* ; B、import java.applet.* ;C、import java.io.* ; D、import java.awt.event.* ;4、 容器 Panel 和 Applet 缺省使用的布局编辑策略是( A )A、BorderLayout B、FlowLayout C、GridLayout D、CardLayout5、 以下哪个不是 Java 的关键字?( A )A、TRUE B、const C、super D、void6、 有程序如下,关于程序的描述哪个是正确的?( A )pu

    20、blic class Person i. static int a = new int10;ii. public static void main(String a) iii. System.out.println( arr1); A、编译将产生错误 B、编译时正确,但运行时将产生错误C、正确,输出 0 D、正确,输出 null7、 以下关于构造函数的描述错误的是( A ) 。A、构造函数的返回类型只能是 void 型。B、构造函数是类的一种特殊函数,它的方法名必须与类名相同。C、构造函数的主要作用是完成对类的对象的初始化工作。D、一般在创建新对象时,系统会自动调用构造函数。8、 有语句 St

    21、ring s=”hello world”; ,以下操作哪个是不合法的?( )A、int i=s.length(); B、s=3; C、String ts=s.trim(); D、String t=s+”!”;9、 有程序片段如下,以下哪个表示式的结果为 true?( A )Float s=new Float(0.1f);Float t=new Float(0.1f);Double u=new Double(0.1);A、s=t B、s.equals(t) C、u.equals(s) D、t.equals(u)10、 欲构造 ArrayList 类的一个实例,此类继承了 List 接口,下列哪个

    22、方法是正确的 ?(B) A、ArrayList myList=new Object () B、List myList=new ArrayList() C、ArrayList myList=new List()D、List myList=new List() ; 11、 paint()方法使用哪种类型的参数? (A)A、Graphics B、Graphics2D C、String D、Color 12、 指出正确的表达式 (C)A、 byte=128; B、Boolean=null; C、 long l=0xfffL; D、 double=0.9239d; 13、 指出下列程序运行的结果 (B)

    23、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“; ch0=g; A、 good and abc B、good and

    24、gbc C、 test ok and abc D、test ok and gbc 14、 运行下列程序, 会产生什么结果 (A)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、 第六行会产生编译错误 C、 第六行会产生运行错误 D、 程序会运行和启动 1

    25、5、 要从文件“ file.dat“文件中读出第 10 个字节到变量 C 中,下列哪个方法适合? (B)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、RandomAcc

    26、essFile in=new RandomAccessFile(“file.dat“); in.skip(9); int c=in.readByte(); 16、 容器被重新设置大小后,哪种布局管理器的容器中的组件大小不随容器大小的变化而改变? (B)CardLayout FlowLayout BorderLayout GridLayout 17、 给出下面代码: (C)public class Person static int arr = new int10;public static void main(String a) System.out.println(arr1); 那个语句是正

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

    28、f j is “ + j ); 7) k = k + 1; 8) I-; 9) 10) A、 line 4 B、 line 6 C、 line 7 D、 line 8 一、 程序阅读1、 阅读以下程序:class Exp1 public static void main(String args) String s,s1=“;char c;s=args0;for (int i=0;i=a int a = 5,1,3,9,7;for ( i = 0 ; i a.length-1; i + ) int k = i;for ( j = i ; j a.length ; j+ )if ( ajak )

    29、k = j;int temp =ai;ai = ak;ak = temp;for ( i =0 ; ia.length; i+ )System.out.print(ai+“ “);System.out.println( );4、 阅读以下程序,写出输出结果 Animal Cat 。class Animal Animal() System.out.print (“Animal “); public class Cat extends Animal Cat() System.out.print (“Cat “); public static void main(String args) Cat k

    30、itty= new Cat(); 5、 阅读以下程序,输出结果为 1 。import java.io.*;public class ATestpublic static void main(String args) SubClass sb = new SubClass( ); System.out.println(sb.funOfMod( ); class SuperClass int a = 10 , b = -3 ; class SubClass extends SuperClass int funOfMod( ) return a%b; 6、 以下程序段的输出结果为 int, int 。

    31、class Crunchervoid crunch( int i )System.out.print(“int”); void crunch(String s)System.out.print(“String”); public static void main(String args )Cruncher crun=new Cruncher ( );char ch=h;int i=12;crun.crunch(ch);/应该是返回 ASCII 码的值System.out.print(“,”);crun.crunch(i); 7、 阅读以下程序,输出结果为 cooljava 。import ja

    32、va.io.*;public class TestString public static void main(String args ) StringC s = new StringC (“cool“,“java“);System.out.println(s); class StringC String s1;String s2;StringC( String str1 , String str2 ) s1 = str1; s2 = str2; public String toString( ) return s1+s2;8、 写出以下程序的运行结果为 s1!=s2 。class Strin

    33、gTest1public static void main(String args) String s1=“hello“;String s2=new String(“hello“);if(s1=s2)System.out.println(“s1=s2“);elseSystem.out.println(“s1!=s2“);1、 编译 Java Applet 源程序文件产生的字节码文件的扩展名为( B )。A、java B、class C、html D、exe2、 Java application 中的主类需包含 main 方法,main 方法的返回类型是什么?( D )A、int B、float

    34、 C、double D、void3、 当浏览器暂时离开含 applet 程序的页面时,以下选项中的哪个方法将被执行?( )A、init() B、start() C、destroy() D、stop()C、Applet D、Dialog 4、 以下标识符中哪项是不合法的( A )A、const B、$double C、helloB、D、BigMeaninglessName5、 以下哪项可能包含菜单条( B )A、Panel B、Frame C、Applet D、Dialog6、 以下关于构造函数的描述错误的是( ) 。A、构造函数的返回类型只能是 void 型。B、构造函数是类的一种特殊函数,它

    35、的方法名必须与类名相同。C、构造函数的主要作用是完成对类的对象的初始化工作。D、一般在创建新对象时,系统会自动调用构造函数。7、 以下关于继承的叙述正确的是( A ) 。A、在 Java 中类只允许单一继承B、在 Java 中一个类只能实现一个接口C、在 Java 中一个类不能同时继承一个类和实现一个接口D、在 Java 中接口只允许单一继承8、 在编写 Java Applet 程序时,若需要对发生的事件作出响应和处理,一般需要在程序的开头写上( D )语句。A、import java.awt.* ; B、B、import java.applet.* ;C、import java.io.* ;

    36、 D、import java.awt.event.* ;9、 下列哪些语句关于 Java 内存回收的说明是正确的 ? ( B )A、程序员必须创建一个线程来释放内存B、内存回收程序负责释放无用内存C、内存回收程序允许程序员直接释放内存D、内存回收程序可以在指定的时间释放内存对象10、 有以下方法的定义,请选择该方法的返回类型( D ) 。ReturnType method(byte x, double y)return (short)x/y*2;A、byte B、short C、int D、double11、 有以下程序片段,下列哪个选项不能插入到行 1。 ( D )1.2.public cl

    37、ass Interesting3./do sth 4. A、import java.awt.*; B、package mypackage;C、class OtherClass D、public class MyClass 12、 以下哪项是接口的正确定义?( B )A、 interface B void print() ;B、 abstract interface B void print() ;C、 abstract interface B extends A1,A2 /A1、A2 为已定义的接口 abstract void print() ;D、 interface B void prin

    38、t();13、 下面哪个函数是 public void aMethod().的重载函数?( D )A、void aMethod( ).B、public int aMethod().C、public void aMethod ( ).D、public int aMethod ( int m).14、 A 派生出子类 B ,B 派生出子类 C,并且在 Java 源代码中有如下声明:1. A a0=new A();2. A a1 =new B();3. A a2=new C();问以下哪个说法是正确的? ( )A、只有第 1 行能通过编译 B、第 1、2 行能通过编译,但第 3 行编译出错C、第 1、2、3 行能通过编译,但第 2、3 行运行时出错D、第 1 行、第 2 行和第 3 行的声明都是正确的 15、 假设 A 类有如下定义,设 a 是 A 类的一个实例,下列语句调用哪个是错误的?( D )class A int i;static String s;void method1() static void method2() A、System.out.println(a.i);B、a.method1(); C、A.method1(); D、A.method2()16、 有如下代码段:

    展开阅读全文
    提示  道客多多所有资源均是用户自行上传分享,仅供网友学习交流,未经上传用户书面授权,请勿作他用。
    关于本文
    本文标题:java期末考试题.doc
    链接地址:https://www.docduoduo.com/p-5526946.html
    关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

    道客多多用户QQ群:832276834  微博官方号:道客多多官方   知乎号:道客多多

    Copyright© 2025 道客多多 docduoduo.com 网站版权所有世界地图

    经营许可证编号:粤ICP备2021046453号    营业执照商标

    1.png 2.png 3.png 4.png 5.png 6.png 7.png 8.png 9.png 10.png



    收起
    展开