1、 请写出该程序的功能: 该程序使用字符缓冲输入流从键盘输入 10 个数,然后倒序并间隔打印出来。2阅读以下程序 import java.io.* ; public class abc public static void main(String args ) int i, s = 0 ;int a = 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120 ; for ( i = 0 ; i=0; i=i-2) ran df.seek(i*4);System,out. prin t(+ra ndf.read In t(); ran df.seek(40);S
2、ystem.out. println(ran df.readUTF(); ran df.close(); catch (IOExce ptio n e) System.out. println (File access error:+e); 该程序的输出结果是:99 65 1 23 66 Good morni ng!4、阅读以下程序并填空。class exte nds Excep ti on H.String mymsg= 我自己定义的异常!double mynum = 2.0;MyException () super(” 首字母不能为 A!) ;MyException (String msg
3、) / 调用父类构造方法,参数为msgp ublic void dis playme() System.out. prin tl n(m ymsg); p ublic double mymethod() retur n Math.sqrt( mynu m);class Excep ti on Test p ublic static void main( Stri ng args) if ( argsO.charAt(O)= A) MyExce ptio n e = new MyExce pti on();kkkk: + e.mymethod();e.dis pl ayme();System.
4、out . println(*in try* ; / 抛出异常e else if(argsO.charAt(O)= B) 第一个字符不应是 B!);throw new MyExce pti on (” else System.out. prin tl n( args0); catch ( ) System.out .prin tl n( aaa.getMessage();aaa.dis playme();System.out. prin tl n(” + aaa.mymethod(); catch( ) System.out .prin tl n( 命令行参数个数错!程序填空:MyExce p
5、tio n sup er(msg) throw eMyExce ptio n aaaArra yin dexOutOfB oun dsExce ptio n5、阅读以下程序import java.io.* ;p ublic class Test p ublic static void main( Stri ng args) SubSubClass m=new SubSubClass(3,6,6); m.show();class Sup erClass int a,b;Sup erClass(i nt x,i nt y) a=x; b=y;class SubClass exte nds Sup
6、erClass int c;SubClass(i nt aa,i nt bb,i nt cc) sup er(aa,bb);c = cc;class SubSubClass exte nds SubClass int a ;SubSubClass(i nt aa,i nt bb,i nt cc) sup er(aa,bb,cc);a = aa + bb + cc;void show() System.out. prin tl n( a=+ a +nb=+ b +nc=+ c); 请写出该程序的运行结果:a=60b=20 c=306、阅读以下程序P ublic class abc p ublic
7、 static void main( Stri ng args) String sl = Hello!;Stri ng s2 = new Strin g(World! System.out. prin tl n( sl.c on cat(s2);请写出该程序的运行结果:HelloWorld!7、阅读以下程序p ublic class Classi p ublic static void main( Stri ng args)int i , max, min;int a = 12,67,8,98,23,56,124,55,99,100);max= mi n= a0;for(i=1;a.le ng
8、th; i+)if( ai max) max = ai;System.out. prin tl n( max + + min);System.out. prin tl n();请写出该程序完成的功能:在数组中查找并输出最大值和最小值。8、阅读以下程序import java.awt.*;import java.a ppi et.A ppi et;p ublic class DrawMylmage exte nds Applet Image mylmage; / 定义一个图像类 Image 的对象 mylmagep ublic void in it()mylmage= getImage(getDo
9、cume ntBase(), pica.j pgp ublic void pain t(Gra phics g) g.drawlmage(mylmage,O,O,this);请写出该程序的功能:在Applet界面中显示当前文件夹下名为Pica.jpg ”的图像。9、阅读以下程序并填空。import java.a ppi et.*;import java .n et.*;App let p ublic class Mypicture _Image image;()p ublic void image=getlmage( new URL(getCodeBase(),image.gif); (Mal
10、formedURLExce pti on e) g.drawlmage(image,O,O, p ublic void start() ();程序填空题: exte nds init catch this repaint10、阅读以下程序:p ublic class Sum p ublic static void main( String args) double sum = 0.0 ;for ( int i = 1;= 100; i + )sum += i;,System.out .println( sum= + sum );该程序完成的功能是:求 sum=1+2+3+.+100 的和。11、阅读以下程序:Sup erClass(i nt x,i nt y) a=x;voidshow() System.out. printin (+ a + n b=+ b);c=cc;voidshow() c=+ c +na=class SubSubClass exte nds SubClass int a;SubSubClass(i nt aa,i nt bb,i nt cc) sup er(aa,bb,cc);a=aa+bb+cc;vo
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1