教学文库网 - 权威文档分享云平台
您的当前位置:首页 > 精品文档 > 建筑文档 >

Java技术:Java期末综合练习题(3)

来源:网络收集 时间:2026-08-25
导读: public class Applet1 extends Applet { public void paint( Graphics g ) { g.drawLine( 30,5,100,45 ); g.drawRect( 30,50,50,20 ); g.drawOval( 30,80,50,40 ); g.drawString( \are figures!\ } } 10.import ja

public class Applet1 extends Applet {

public void paint( Graphics g ) {

g.drawLine( 30,5,100,45 ); g.drawRect( 30,50,50,20 ); g.drawOval( 30,80,50,40 );

g.drawString( \are figures!\ } }

10.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>b)?a:b); } } 三、写出下面程序的运行结果。 1.import java.io.*;

public class abc

{ public static void main(String args[ ])

{ AB s = new AB(\ System.out.println(s.toString( )); } }

class AB { String s1; String s2;

AB( String str1 , String str2 ) { s1 = str1; s2 = str2; } public String toString( ) { 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 ( a[i]%3 = = 0 ) s += a[i] ; System.out.println(\ } }

3. import java.io.* ; public class abc {

public static void main(String args[ ])

{ SubSubClass x = new SubSubClass(10 , 20 , 30); x.show(); } }

class SuperClass { int a,b;

SuperClass(int aa , int bb) { a=aa; b=bb; } void show( )

{ System.out.println(\} }

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); a=aa+bb+cc; }

void show()

{ System.out.println(\ }

4. import java.io.*; public class abc {

public static void main(String args[]) {

String s1 = \

String s2 = new String(\ System.out.println(s1.concat(s2)); } }

5. import java.io.* ; public class ABC {

public static void main(String args[ ]) { int i ;

int a[ ] = { 11,22,33,44,55,66,77,88,99 }; for ( i = 0 ; i <= a.length / 2 ; i ++ )

System.out.print( a[i]+a[a.length-i-1]+\\ System.out.println( ); } }

6. import java.io.*; class Parent {

void printMe() {

System.out.println(\ } }

}

class Child extends Parent {

void printMe() {

System.out.println(\ }

void printAll() {

super.printMe(); this.printMe(); printMe(); } }

public class Class1 {

public static void main(String args[ ]) {

Child myC = new Child( ); myC.printAll( ); } }

参考答案

一、选择题。

1.B 2.B 3.A 4.B 、 C 5.A 6.B 7.B 8.C 9.C 10.A、C、D

11.A、C、D 12.A 13.D 14.B、D 15.B、D 16.B 17.A 18.C 19.C 20.A、B、D 21.D 22.D 23.D 24.D 25.B

26.D 27.A 28.D 29.C 30.D 31.D 32.D 33.D 34.B 35.D 36.D 37.C 38.B 39.D 41.B 42.C 43.A 44.C 45.B 47.A 48.D 49.B 50.C 51.A 53.C 54.C 55.A 56.B 57.C 59.A 60.D 61.C 62.D 63.B 65.A 66.A 67.A 68.C 69.C 71.B 72.D 73.C 74.B 75.A 77.C 78.D 79.A 80.B

二、写出下列程序完成的功能。

1.计算 1/1+1/2+1/3+...+1/100 的值。2.从标准输入(即键盘)读入10个整数存入整型数组个整数。

3.创建一个标题为\按钮\的窗框,窗框中显示有4.在数组中查找并输出最大值和最小值。5.使用选择法对数组a的数据进行升序排序,然后输出排序后的结果。6.定义一个计算n!的类Fact,然后主类中创建一个对象求解7.在Applet界面中显示当前文件夹下名为8.定义一个计算xn的类,然后用该类求9.在Applet界面中显示一些由直线、矩形框、椭圆框和文字组成的图形。10.求两个数的最大值。 三、写出下面程序的运行结果。 1.Hello! I love JAVA. 2.s = 180 3.a=60 b=20 c=30

4.Hello! World!

5.110 110 110 110 110 6.parent child child

40.D 46.C 52.B 58.D 64.C 70.D 76.C a中,然后逆序输出这\按下我

\的图像。103的值。

\字样的按钮。4!的值。 10

…… 此处隐藏:1052字,全部文档内容请下载后查看。喜欢就下载吧 ……
Java技术:Java期末综合练习题(3).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.jiaowen.net/wendang/680899.html(转载请注明文章来源)
Copyright © 2020-2025 教文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:78024566 邮箱:78024566@qq.com
苏ICP备19068818号-2
Top
× 游客快捷下载通道(下载后可以自由复制和排版)
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能出现无法下载或内容有问题,请联系客服协助您处理。
× 常见问题(客服时间:周一到周五 9:30-18:00)