java期末考试题.doc

上传人:h**** 文档编号:1300478 上传时间:2019-02-06 格式:DOC 页数:37 大小:145KB
下载 相关 举报
java期末考试题.doc_第1页
第1页 / 共37页
java期末考试题.doc_第2页
第2页 / 共37页
java期末考试题.doc_第3页
第3页 / 共37页
java期末考试题.doc_第4页
第4页 / 共37页
java期末考试题.doc_第5页
第5页 / 共37页
点击查看更多>>
资源描述

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

2、n 类型数据只有 2个值, true 和 false C数组属于简单数据类型 D Java 中的指针类型和 C语言的一样 4、设 int x=1,float y=2,则表达式 x / y 的值是:( D) A 0 B 1 C 2 D以上都不是 5、以下语句有语法错的是:( A) A int x=1; y=2; z=3 B for (int x=10,y=0; x0; x+); C while (x5); D for(; ;); 6、关于类和对象的叙述正确的是:( A) A Java 的类分为两大部分:系统定义的类和用户自定义的类 B类的静态属性和全局变量的概念完全一样,只是表达形式不同 C类的

3、成员至少有一个属性和一个方法 D类是对象的实例化 7、以下有关构造方法的说法,正确的是:( A) A一个类的构造方法可以有多个 B构造方法在类定义时被调用 C构造方法只能由对象中的其它方法调用 D构造方法可以和类同名,也可以和类名不同 8、以下有关类的继承的叙述中,正确的 是:( D) A子类能直接继承父类所有的非私有属性,也可通过接口继承父类的私有属性 B子类只能继承父类的方法,不能继承父类的属性 C子类只能继承父类的非私有属性,不能继承父类的方法 D子类不能继承父类的私有属性 9、下列属于容器的组件有:( B) A JButton B JPane C Canvas D JTextArea

4、10、 void 的含义:( C) A方法体为空 B定义的方法没有形参 C定义的方法没有返回值 D方法 的返回值不能参加算术运算 11、关于 Java 中异常的叙述正确的是:( D) A异常是程序编写过程中代码的语法错误 B异常是程序编写过程中代码的逻辑错误 C异常出现后程序的运行马上中止 D异常是可以捕获和处理的 12、所有的异常类皆继承哪一个类?( C) A java.io.Exception B java.lang.Throwable C java.lang.Exception D java.lang.Error 13、下面哪个不是 java 语言中的关键 字?( B) A long B

5、 sizeof C instanceof D const 14、为实现进程之间的通信,需要使用下列那种流才合适?( D) A Data stream B File stream C Buffered stream D Piped stream 15、在复选框中移动鼠标,然后单击一选项,要捕获所选项必需实现哪个接口?( D) A ActionListener B MouseListener C MouseMotionListern D ItemListener 二、填空题(每空 1分,共 20分) 1、面向对象程序设计所具有的基本特征是: _抽象性 _, _封装性 _, _继承性 _, _多态性

6、 _ 2、数组 x定义如下 int x =new int32 则 x.length 的值为 _3_, x0.length 的值为 _2_。 3、 Java 中实现多线程一般使用两种方法,一是 _继承 Thread 类 _,二是 _实现 Runnable 方法 _ 4、 Java 的图形用户界面设计中,有很多布局管理器用来摆放组件的位置,一般用到的布局管理器有(列出四种即可) _FlowLayout_, _GridLayout_,_BorderLayout_, _CardLayout_ 5、 Applet 常用的方法是: _init()_、 _run() _、 _stop()_和 destroy

7、()。 三、阅读程序,写出程序的输出结果(每题 5分,共 20分) 1、 class A private int privateVar; A(int _privateVar) privateVar=_privateVar; boolean isEqualTo(A anotherA) if(this.privateVar = anotherA.privateVar) return true; else return false; public class B public static void main(String args) A a = new A(1); A b = new A(2);

8、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 static void main(String args) B obj = new B(); System.out.println(“The program output is “ + obj.f(4, 6); 程

9、序的输出结果为: _ 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 method() try wrench(); System.out.println(“C“); catch (ArithmeticException e) System.out.println

10、(“D“); finally System.out.println(“E“); System.out.println(“F“); static void wrench() throw new NullPointerException(); 程序的输出结果为: E A B 4、 public class Test public static void main(String args) int x; int a = 0, 0, 0, 0, 0, 0 ; calculate(a, a5); System.out.println(“the value of a0 is “ + a0); System

11、.out.println(“the value is a5 is “ + a5); static int calculate(int x, int y) for (int i = 1; i = y的逻辑值分别为 和 。 7、 方法是一种仅有方法头,没有具体方法体和操作实现的方法,该方法必须在抽象类之中定义。 方法是不能被当前类的子类重新定义的方法。 8 、 创 建 一 个 名 为 MyPackage 的包的语句是 , 该语句应该放在程序的位置为: 。 9、设有数组定义: int MyIntArray = 10 , 20 , 30 , 40 , 50 , 60 , 70; 则执行以下几个语句后的

12、输出结果是 。 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 为系统定 Button btn; / 义的窗框类 FrameOut( ) super(“按钮 “); btn = new Button(“按下我

13、 “); 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 ; class SubClass extends SuperClass int max( ) return (a

14、b)?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 ) s1 = str1; s2 = str2; public String toString(

15、 ) return s1+s2; 2、 import java.io.* ; public class abc public static void main(String args ) int i , s = 0 ; int a = 10 , 20 , 30 , 40 , 50 , 60 , 70 , 80 , 90 ; for ( i = 0 ; i a.length ; i + ) if ( ai%3 = = 0 ) s += ai ; System.out.println(“s=“+s); 3、 import java.io.* ; public class abc public static void main(String args ) ) System.out.println(“a=“+a+“nb=“+b); class SubClass extends SuperClass int c; SubClass(int aa,int bb,int cc) super(aa,bb); c=cc; class SubSubClass extends SubClass int a; SubSubClass(int aa,int bb,int cc) super(aa,bb,cc);

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

当前位置:首页 > 教育教学资料库 > 试题真题

Copyright © 2018-2021 Wenke99.com All rights reserved

工信部备案号浙ICP备20026746号-2  

公安局备案号:浙公网安备33038302330469号

本站为C2C交文档易平台,即用户上传的文档直接卖给下载用户,本站只是网络服务中间平台,所有原创文档下载所得归上传人所有,若您发现上传作品侵犯了您的权利,请立刻联系网站客服并提供证据,平台将在3个工作日内予以改正。