java试卷a及答案

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

《java试卷a及答案》由会员分享,可在线阅读,更多相关《java试卷a及答案(4页珍藏版)》请在金锄头文库上搜索。

1、 JAVA 程序设计 试卷 A 卷出卷教师: 适应班级:考试方式:闭卷 本试卷考试分数占学生总评成绩的 70 %题号 一 二 三 四 五 总分 核分人得分复查总分 总复查人 (本题 20 分)一、选择题(每小题 1 分,共 20 分)1、定义一个类,必须使用的关键字是( )A、public B、class C、interface D、static2、定义类头时能使用的修饰符是( )。 A) private B) static C) abstract D) protected3、定义一个接口必须使用的关键字是( )A、public B、class C、interface D、static4、声明

2、并创建一个按钮对象 b,应该使用的语句是( )A、Button b=new Button(); B、button b=new button();C、Button b=new b(); D、b.setLabel(“确定”);5、以下哪个方法用于定义线程的执行体? ( )A、 start() B、init() C、run() D、synchronized() 6、在使用 interface 声明一个接口时,只可以使用( )修饰符修饰该接口。A、private B、protected C、private protected D、public7、Java application 中的主类需包含 mai

3、n 方法,main 方法的返回类型是什么?( )A、int B、float C、double D、void8在编写 Java Applet 程序时,若需要对发生的事件作出响应和处理,一般需要在程序的开头写上( )语句。A、import java.awt.* ; B、import java.applet.* ;C、import java.io.* ; D、import java.awt.event.* ;9、下面的代码段执行之后 count 的值是什么( )int count = 1;for (int i = 1; i = y 的逻辑值分别为 和 。15、设 x = 2 ,则表达式 ( x +

4、+ )3 的值是 。(本题 20 分)三、写出下列程序的结果(每小题 4 分,共 20 分)1、以下程序段的输出结果是( )int x = 5, y = 6, z = 4;if (x + y z & x + z y & z + y x)System.out.println(三角形);elseSystem.out.println(不是三角形);2、import java.io.*;public class abc public static void main(String args) SubClass sb = new SubClass( ); System.out.println(sb.ma

5、x( );class SuperClass int a = 10 , b = 20 ; class SubClass extends SuperClass int max( ) return (ab)?a:b); 3、 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 , St

6、ring str2 ) s1 = str1; s2 = str2; public String toString( ) return s1+s2;4、写出以下程序的运行结果。public class TestArray public static void main(String args ) int i , j ;int a = 1,3,2,5,4;for ( i = 0 ; i ak ) k = j;int temp =ai;ai = ak;ak = temp; for ( i =0 ; i 6、String str;int arr = new int10; 7、import mypack

7、age.*; 8、int,arr,5,0 到 4。 9、true,boolean 10、try、catch 11、编辑源程序 、 编译生成字节码 和 解释运行字节码 。 12、MyApplet 13、 javac.exe 3 . class 14、 true 和 false 15、 13、读程序题(20 分)1、三角形 2、求两个数的最大值。 3、答:1、Hello! I love JAVA.4、54321 5、Animal Cat4、综合题(30 分)1编写一个输出Welcome to Java World!的 Applet 程序和嵌入该 Applet 的 HTML 页面。 / Welcom

8、e.java/Welcome.htmlimport java.applet.*;import java.awt.*;public class Welcome extends Applet public static String str=null;public void init() str=Welcome to Java World !;public void paint(Graphics g) g.drawString(str, 10, 50);2、编写一个字符界面的 Java Application 程序,接受用户输入的 10 个整数,并输出这10 个整数的最大值和最小值。答:impor

9、t java.io.* ;public class abc public static void main(String args ) int i , n = 10 , max = 0 , min = 0 , temp = 0;try BufferedReader br = new BufferedReader(new InputStreamReader(System.in);max = min = Integer.parseInt(br.readLine( ); catch ( IOException e ) ;for ( i = 2 ; i max ) max=temp;if (temp min) min=temp; catch ( IOException e ) ;System.out.println(max=+max+nmin=+min);

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


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

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