收藏 分享(赏)

JAVA语言程序设计期末考试模拟试题new.doc

上传人:dzzj200808 文档编号:2280901 上传时间:2018-09-09 格式:DOC 页数:10 大小:64.50KB
下载 相关 举报
JAVA语言程序设计期末考试模拟试题new.doc_第1页
第1页 / 共10页
JAVA语言程序设计期末考试模拟试题new.doc_第2页
第2页 / 共10页
JAVA语言程序设计期末考试模拟试题new.doc_第3页
第3页 / 共10页
JAVA语言程序设计期末考试模拟试题new.doc_第4页
第4页 / 共10页
JAVA语言程序设计期末考试模拟试题new.doc_第5页
第5页 / 共10页
点击查看更多>>
资源描述

1、 http:/ 免费提供各种资格考试真题、模拟题、练习题、精选题及答案http:/ 免费提供各种资格考试真题、模拟题、练习题、精选题及答案JAVA语言程序设计期末考试模拟试题一、单选择题( 每小题 2 分,共 10 分)1、编译 Java Application 源程序文件将产生相应的字节码文件,这些字节码文件的扩展名为( )。A. .java B. .classC. .html D. .exe2、设 x = 1 , y = 2 , z = 3,则表达式 yz/x 的值是( )。A. 3 B. 3. 5C. 4 D. 53、在 Java Applet 程序用户自定义的 Applet 子类 中,

2、一般需要重 载父类的( )方法来完成一些画图操作。A. start( ) B. stop( )C. init( ) D. paint( )4、不允许作为类及类成员的访问控制符的是( )。A. public B. privateC. static D. protected5、为 AB 类的一个无形式参数无返回值的方法 method 书写方法头,使得使用类名AB 作为前缀就可以调用它, 该方法头的形式为( )。A. static void method( ) B. public void method( ) C. final void method( ) D. abstract void meth

3、od( )二、填空题(每空格 1 分,共 20 分)1、开发与运行 Java 程序需要经过的三个主要步骤为 、和 。2、如果一个 Java Applet 源程序文件只定义有一个 类,该类的类名为 MyApplet,则类 MyApplet 必须是 类的子类并且存储该源程序文件的文件名为 。http:/ 免费提供各种资格考试真题、模拟题、练习题、精选题及答案http:/ 免费提供各种资格考试真题、模拟题、练习题、精选题及答案3、如果一个 Java Applet 程序文件中定义有 3 个类, 则使用 Sun 公司的 JDK 编译器 编译该源程序文件将产生 个文件名与类名相同而扩展名为 的字节码文件。

4、4、在 Java 的基本数据类型中,char 型采用 Unicode 编码方案,每个 Unicode 码占用 字节内存空间,这样,无 论是中文字符还是英文字符,都是占用 字节内存空间。5、设 x = 2 ,则表达式 ( x + + )3 的值是 。6、若 x = 5,y = 10,则 x = y 的逻辑值分别为 和 。7、 方法是一种 仅有方法头,没有具体方法体和操作实现的方法,该方法必须在抽象类之中定义。 方法是不能被当前类的子类重新定义的方法。8、创建一个名为 MyPackage 的包的语句是 ,该语句应该放在程序的位置为: 。9、设有数组定义:int MyIntArray = 10 ,

5、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 为系统定 Button btn; / 义的窗框类FrameOut( ) su

6、per(“按钮“);btn = new Button(“按下我“);http:/ 免费提供各种资格考试真题、模拟题、练习题、精选题及答案http:/ 免费提供各种资格考试真题、模拟题、练习题、精选题及答案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( );cla

7、ss SuperClass int a = 10 , b = 20 ; 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;Strin

8、g s2;AB( String str1 , String str2 ) s1 = str1; s2 = str2; public String toString( )http:/ 免费提供各种资格考试真题、模拟题、练习题、精选题及答案http:/ 免费提供各种资格考试真题、模拟题、练习题、精选题及答案 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 , 8

9、0 , 90 ;for ( i = 0 ; i max ) max=temp;if (temp min) min=temp; catch ( IOException e ) ;System.out.println(“max=“+max+“nmin=“+min); 2、参考程序如下:import java.applet.* ; import java.awt.* ;public class abc extends Applet Complex a,b,c ;public void init( ) a = new Complex(1,2); b = new Complex(3,4); http:/

10、 免费提供各种资格考试真题、模拟题、练习题、精选题及答案http:/ 免费提供各种资格考试真题、模拟题、练习题、精选题及答案c = new Complex(); public void paint(Graphics g) c=plexAdd(b);g.drawString(“第一个复数: “+a.toString(),10,50);g.drawString(“第二个复数: “+b.toString(),10,70);g.drawString(“两复数之和: “+c.toString(),10,90);class Complexint RealPart ; / 复数的实部 int ImaginP

11、art ; / 复数的虚部Complex() RealPart = 0 ; ImaginPart = 0 ; Complex(int r , int i) RealPart = r ; ImaginPart = i ; Complex complexAdd(Complex a) Complex temp = new Complex( ); / 临时复数对象temp.RealPart=RealPart+a.RealPart;temp.ImaginPart=ImaginPart+a.ImaginPart;return temp;public String toString( ) return ( RealPart+“ + “+ImaginPart+“ i “); (完)http:/ 免费提供各种资格考试真题、模拟题、练习题、精选题及答案http:/ 免费提供各种资格考试真题、模拟题、练习题、精选题及答案

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 高等教育 > 大学课件

本站链接:文库   一言   我酷   合作


客服QQ:2549714901微博号:道客多多官方知乎号:道客多多

经营许可证编号: 粤ICP备2021046453号世界地图

道客多多©版权所有2020-2025营业执照举报