java期末复习1

上传人:第*** 文档编号:34022966 上传时间:2018-02-20 格式:DOC 页数:5 大小:57KB
返回 下载 相关 举报
java期末复习1_第1页
第1页 / 共5页
java期末复习1_第2页
第2页 / 共5页
java期末复习1_第3页
第3页 / 共5页
java期末复习1_第4页
第4页 / 共5页
java期末复习1_第5页
第5页 / 共5页
亲,该文档总共5页,全部预览完了,如果喜欢就下载吧!
资源描述

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

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

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

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

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

5、tanceof Dconst 14、为实现进程之间的通信,需要使用下列那种流才合适?(D) AData stream BFile stream CBuffered stream DPiped stream15、在复选框中移动鼠标,然后单击一选项,要捕获所选项必需实现哪个接口?(D) AActionListener B MouseListener C MouseMotionListern DItemListener 二、填空题(每空 1 分,共 20 分) 1、面向对象程序设计所具有的基本特征是:_抽象性_,_封装性_,_继承性_,_多态性.2、数组 x 定义如下 int x =new int3

6、2 则 x.length 的值为 _3_, x0.length 的值为_2_。 3、Java 中实现多线程一般使用两种方法,一是_继承 Thread 类_,二是_实现 Runnable 方法_ 4、Java 的图形用户界面设计中,有很多布局管理器用来摆放组件的位置,一般用到的布局管理器有(列出四种即可)_FlowLayout_,_GridLayout_,_BorderLayout_,_CardLayout_三、阅读程序,写出程序的输出结果(每题 5 分,共 20 分) 1、class A private int privateVar; A(int _privateVar) privateVar

7、=_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); System.out.println(a.isEqualTo(b); 程序的输出结果为:_false_2、class A double f(double x, double y) return x

8、 * 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); 程序的输出结果为:_ The program output is 10_ 3、public class Unchecked public static void main(String args) try me

9、thod(); 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(D); finally System.out.println(E); System.out.println(F); static void wrench() throw new NullPointerException();

10、 程序的输出结果为: E AB 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.out.println(the value is a5 is + a5); static int calculate(int x, int y) for (int i = 1; i y | x z B) x != y D) C) z ( y +

11、x ) D) x y & ! ( x z ) 填空题 1.构造函数_没_有返回值。 2.Java 语言中的浮点型数据根据数据存储长度和数值精度的不同,进一步分为 float 和_ double _两种具体类型。 3.请完善下面 Java 应用程序 ,是一个类的定义: public class _int Myclass_ int x, y; Myclass ( int i, int j) / 构造函数 x=i; y=j; 4.请完善下面 Java 应用程序,使其运行时输出:class myThread implements Runnable int a = 1, 2, 3;m(a); publi

12、c static void m(int x) for(int i=0;ix.length;i+) System.out.println(a + i + = + xi); public class Test public static void main(String args) Thread t = new Thread( _ ); t. _ public void run() 、 new myThread() 、 start() . 5.以下方法 m 的功能是求两参数之积的整数部分。 int m ( float x, float y ) _int_k=(int)x*y_; 编程题 1.编写一

13、个圆形类 Circle,包含:(1)一个 public 属性:圆形的半径 rad。(2)两个构造方法:一个带有一个参数、一个不带参数的构造方法,其中不带参数的构造方法将圆形初始化为半径为 10.0。 (3)两个方法:求圆形面积的方法 mianji()和求圆形周长的方法 zhouchang()。 (4) 获取圆形半径的方法 getRad(); class Circle public double rad; public Circle () rad=10.0; public Circle (double r) rad=r; public double mianji() return 3.14159*rad*rad; public double zhouchang() return 2*3.14159*r; public double getRad() return rad; 用接口 interface Singger abstract public void sing();来模拟民歌(Folk) ,流行(Pop) ,摇滚(R

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

当前位置:首页 > 办公文档 > 解决方案

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