JAVA应用开发模拟试卷B 一、选择题(20题,每题2分,共40分) L.在面向对象的方法中,一个对象请求另一个对象为其服务的方式是通过发送() A、调用语句 B、命令 C、口令 D、消息 2.Java语言具有许多优点和特点,下列选项中,哪个反映了Java程序并行机制的特点:() A、安全性 B、多线程 C、跨平台 D、可移值 3.编写和运行Java applet程序与编写和运行Java application程序不同的步骤是:() A、编写源代码 B、编写HTL文件调用该小程序,以.html为扩展名存入相同文件夹 C、编译过程 D、解释执行 4.Java的字符类型采用的是Unicode编码方案,每个Unicode码占用个比特位。() A、8 B、16 C、32 D、64 5.关于下列程序段的输出结果,说法正确的是:() public class MyClass{ static int i; public static void main(String argv[]){ System.out.println(i); A、有错误,变量1没有初始化。 B、nul1 C、1 D、0 6.下列代码的执行结果是:( public class Test3{ public static void main(String args[]){ System.out.print (100%3); System.out.print(",") System.out.println(100%3.0); } 八 A、1,1 B、1,1.0 C、1.0,1
JAVA 应用开发模拟试卷 B 一、选择题(20 题,每题 2 分,共 40 分) 1.在面向对象的方法中,一个对象请求另一个对象为其服务的方式是通过发送 ( ) A、调用语句 B、命令 C、口令 D、消息 2.Java 语言具有许多优点和特点,下列选项中,哪个反映了 Java 程序并行机制的特点:( ) A、安全性 B、多线程 C、跨平台 D、可移值 3.编写和运行 Java applet 程序与编写和运行 Java application 程序不同的步骤是:( ) A、编写源代码 B、编写 HTML 文件调用该小程序,以.html 为扩展名存入相同文件夹 C、编译过程 D、解释执行 4.Java 的字符类型采用的是 Unicode 编码方案,每个 Unicode 码占用____个比特位。( ) A、8 B、16 C、32 D、64 5.关于下列程序段的输出结果,说法正确的是:( ) public class MyClass{ static int i; public static void main(String argv[]){ System.out.println(i); } } A、有错误,变量 i 没有初始化。 B、null C、1 D、0 6.下列代码的执行结果是:( ) public class Test3{ public static void main(String args[]){ System.out.print(100%3); System.out.print(","); System.out.println(100%3.0); } } A、1,1 B、1,1.0 C、1.0,1
D、1.0,1.0 7.下列程序段的输出结果是:( void complicatedExpression(){ intx=20,y=30: boolean b; b=x>50&&y>60x>50&&y<-60|x<-50&&y>60x<-50&&y<-60: System.out.println(b); A、true B、false C、1 D、0 8.给出下列代码片段:( ) if(x>0)(System.out.println("first"):} else if(x>-3){System.out.println("second"): else {System.out.println("third"): 请问x处于什么范围时将打印字符串“second”? A、x>0 B、x>-3 C、x<-3 D、x=0&x>-3 9.若要把变量声名为暂时性变量,应使用如下哪种修饰符?() A、protected B、provate C、transient (临时变量) D、volatile(共享变量) 10.在Java中,一个类可同时定义许多同名的方法,这些方法的形式参数的个数、类型 或顺序各不相同,传回的值也可以不相同,这种面向对象程序特性称为:( A、隐藏 B、覆盖 C、重载 D、Java不支持此特性 11.如要抛出异常,应用下列哪种子句?() A、catch B、throws C、try D、finally I2.在使用interface声明一个接口时,只可以使用修饰符修饰该接口。( ) A、private B、protected C、private protected D、public 13.下列代码的输出结果是:( class Parent{
D、1.0,1.0 7.下列程序段的输出结果是:( ) void complicatedExpression(){ int x=20, y=30; boolean b; b=x>50&&y>60||x>50&&y<-60||x<-50&&y>60||x<-50&&y<-60; System.out.println(b); } A、true B、false C、1 D、0 8.给出下列代码片段:( ) if(x>0){System.out.println("first");} else if(x>-3){ System.out.println("second");} else {System.out.println("third");} 请问 x 处于什么范围时将打印字符串“second”? A、x>0 B、x>-3 C、x<=-3 D、x<=0 &&x>-3 9.若要把变量声名为暂时性变量,应使用如下哪种修饰符?( ) A、protected B、provate C、transient (临时变量) D、volatile (共享变量) 10.在 Java 中,一个类可同时定义许多同名的方法,这些方法的形式参数的个数、类型 或顺序各不相同,传回的值也可以不相同,这种面向对象程序特性称为:( ) A、隐藏 B、覆盖 C、重载 D、Java 不支持此特性 11.如要抛出异常,应用下列哪种子句?( ) A、catch B、throws C、try D、finally 12.在使用 interface 声明一个接口时,只可以使用____修饰符修饰该接口。( ) A、private B、protected C、private protected D、public 13.下列代码的输出结果是 : ( ) class Parent{
void printMe(){ System.out.println("parent"); } class Child extends Parent void printMe(){ System.out.println("child"); void printall(){ super.printMe(); this.printMe(); printMe() public class Test_this public static void main(String args[]){ Child myC=new Child(); myC.printall(); } A、parent child child B、parent child parent C、parent child D、编译错误 14.为读取的内容进行处理后再输出,需要使用下列哪种流?( A、File stream B、Pipe stream C、Random stream D、Filter stream 15.为实现多线程之间的通信,需要使用下列哪种流才合适?( A、Filter stream B、File stream C.Random access stream D、Piped stream l6.Swing与aWT的区别不包括:( A、Swing是由纯Java实现的轻量级构件 B、Swing没有本地代码 C、Swing不依赖操作系统的支持 D、Swing支持图形用户界面
void printMe() { System.out.println("parent"); } }; class Child extends Parent { void printMe() { System.out.println("child"); } void printall() { super.printMe(); this.printMe(); printMe(); } } public class Test_this { public static void main(String args[]) { Child myC=new Child(); myC.printall(); } } A、parent child child B、parent child parent C、parent child D、编译错误 14.为读取的内容进行处理后再输出,需要使用下列哪种流? ( ) A、File stream B、Pipe stream C、Random stream D、Filter stream 15.为实现多线程之间的通信,需要使用下列哪种流才合适?( ) A、Filter stream B、File stream C、Random access stream D、Piped stream 16.Swing 与 aWT 的区别不包括 :( ) A、Swing 是由纯 Java 实现的轻量级构件 B、Swing 没有本地代码 C、Swing 不依赖操作系统的支持 D、Swing 支持图形用户界面
17.在编写Java applet程序时,若需要对发生事件作出响应和处理,一般需要在程序的 开头写上语句。 () A、import java.awt.*: B.import java.applet.* C、import java.io.*; D,import java.awt.event.* 18.注释的基本原则不包括:( A、注释应该增加代码的清晰度 B、注释要简洁 C、在写代码之前写注释 D、尽量给每一条语句加注释 19.jva.io包中定义了多个流类型来实现输入和输出功能,可以从不同的角度对其进行分类,按功能分为: (C) A、输入流和输出流 (方向) B、字节流和字符流 (内容) C、节点流和处理流 (分工) 20.以下程序的运行结果为( public class IfTest public static void main(String args[]){ int x=3: int y=1; if(x==y) System.out.println("Not equal"); else System.out.println("Equal"); } A)Not equal B)Equal C)无输出 D)编译出错 二.填空题(每空1.5分,共15分) l.java.io包中的和 类主要用于对对象(0 bject)的读写。(serializable) 2.在编写异常处理的Java程序中,每个catch语句块都应该与 语句块对应,使得用该语句块来启 动Java的异常处理机制。 3.顺序执行以下两个语句的输出结果是: String s="我喜欢学习Java!"; System.out.println(s.length()): 4.Java语言通过接口支持_继承,使类继承具有更灵活的扩展性。 5.实例化对象:就是创建一个对象。用运算符来实现对象的实例化 6.我们用_一来定义一个整数,用一来定义一个字符类型,称为原始数据类型。 7.当用户在TextField中输入一行文字后,按回车,实现接口可实现对事件的响应。 8.包含Swing构件的Applet(小应用程序)应该是__类的子类。 三、写出下列程序的运行结果(每空5分,共15分) 1.下列程序的输出结果为: public class TestApple
17.在编写 Java applet 程序时,若需要对发生事件作出响应和处理,一般需要在程序的 开头写上____语句。 ( ) A、import java.awt.*; B、import java.applet.*; C、import java.io.*; D、import java.awt.event.*; 18.注释的基本原则不包括:( ) A、注释应该增加代码的清晰度 B、注释要简洁 C、在写代码之前写注释 D、尽量给每一条语句加注释 19.java.io 包中定义了多个流类型来实现输入和输出功能,可以从不同的角度对其进行分类,按功能分为: ( C ) A、输入流和输出流 (方向) B、字节流和字符流 (内容) C、节点流和处理流 (分工) 20. 以下程序的运行结果为( ) public class IfTest{ public static void main(String args[]){ int x=3; int y=1; if(x==y) System.out.println("Not equal"); else System.out.println("Equal"); } } A)Not equal B)Equal C)无输出 D)编译出错 二.填空题(每空 1.5 分,共 15 分) 1.java.io 包中的 _______和_ ________类主要用于对对象(Object)的读写。(serializable) 2.在编写异常处理的 Java 程序中,每个 catch 语句块都应该与__ _____语句块对应,使得用该语句块来启 动 Java 的异常处理机制。 3. 顺序执行以下两个语句的输出结果是: ___。 String s="我喜欢学习 Java!"; System.out.println(s.length()); 4. Java 语言通过接口支持_ ___继承,使类继承具有更灵活的扩展性。 5. 实例化对象:就是创建一个对象。用____运算符来实现对象的实例化。 6.我们用_ ____来定义一个整数,用__ ___来定义一个字符类型,称为原始数据类型。 7. 当用户在 TextField 中输入一行文字后,按回车,实现_____接口可实现对事件的响应。 8. 包含 Swing 构件的 Applet(小应用程序)应该是__ ___类的子类。 三、写出下列程序的运行结果(每空 5 分,共 15 分) 1.下列程序的输出结果为: public class TestApple {
int i=0; Apple(int i){ this.i=i; } Apple increament () it+; return this; } void print(){ System.out.println("i="+i); public static void main(String[]args){ Apple redapple=new Apple(1000): redapple.increament().increament().print () } 2.下列程序的输出结果为: class SuperClass{ private int n; SuperClass(){ System.out.println("SuperClass()"); } SuperClass(int n){ System.out.println ("SuperClass ("+n+")"); } class SubClass extends SuperClass{ private int n; SubClass(int n){ super(): System.out.println("SubClass("+n+")"); this.n=n; } SubClass(){ super (300): System.out.println("SubClass()"): } public class TestSuperSub public static void main(String args[]){ SubClass sc=new SubClass(400); } 结果:
int i=0; Apple(int i){ this.i=i; } Apple increament(){ i++; return this; } void print(){ System.out.println("i="+i); } public static void main(String[] args) { Apple redapple=new Apple(1000); redapple.increament().increament().print(); } 2. 下列程序的输出结果为: class SuperClass{ private int n; SuperClass(){ System.out.println("SuperClass()"); } SuperClass(int n){ System.out.println("SuperClass("+n+")"); } } class SubClass extends SuperClass{ private int n; SubClass(int n){ super(); System.out.println("SubClass("+n+")"); this.n=n; } SubClass(){ super(300); System.out.println("SubClass()"); } } public class TestSuperSub { public static void main(String args[]){ SubClass sc=new SubClass(400); } } 结果: