版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、1、阅读以下程序,输出结果为 。class Q1public static void main(String args ) double d=1.23;Dec dec =new Dec();dec.decreme nt(d);System.out.pri ntl n( d);classs Decpublic void decreme nt(double decMe) decMe = decMe 0.1;9 / 82、以下程序段的输出结果为class Crun chervoid crun ch( int i )System.out.pri ntl n(void crun ch(Stri ng s
2、)System.out.pri ntl n(public static void main(String args )Cruncherint version );String version ” );char ch= crun.crun ch(ch);crun=newP;Crun cher ();3、阅读以下程序段:class Pare ntvoid prin tMe()System.out.println(“pt ” );class Child exte nds Pare ntvoid prin tMe()System.out.print (“cd” );void prin tAll()su
3、per.pri ntMe();this.pri ntMe();prin tMe();public class Test_thispublic static void main(String args)Child myC=new Child();myC.pri ntAII();输出结果为 。4、已有Bird类的定义如下:package abcde;public class Birdprotected static int referen ceCo un t=0;public Bird() referen ceCo un t+; protected void fly() static int ge
4、tReCo unt() return referenceCount; 有类 Night in gale的定义如下,请写出它的输出结果 packagesin gers ;class Night in gale exte nds abcde.BirdNight in gale() referen ceCo un t+;public static void main( String args)System.out.print( “ Before: ” +referenceCount);Nighti ngale flore nce=new Nighti ngale();System.out.pri n
5、tl n(“ After:” +refere nceCo un t);flore nce.fly();5、 以下程序段的输出结果为 。public class testpublic static void main(String args)Strin gBuffer s = new Strin gBuffer(Hello);s.appe nd(there);System.out.pri ntl n( s);String pf = s.substring(0, s.length();System.out.pri ntln( pf.equals(Hellothere);6、 以下程序段的输出结果为
6、 。class Pers onpublic Pers on()System.out.pri ntl n(hi!);public Person( Stri ng s)this();System.out.println(I am +s);public class Who exte nds Personpublic Who()this(I am Tony);public Who(Stri ng s)super(s);System.out.println(How do you do?);public static void main(String args)Who w = new Who(Tom);7
7、. 下面是一个类的定义。class/ 定义名为 MyClass的类int var=666;static int getvar() retur n var;&以下程序的输出结果为 public class abcpublic static void main(String args) SubSubClass x = new SubSubClass(10,20,30);x.show();class SuperClass int a,b;SuperClass(i nt aa , int bb) a=aa; b=bb; void show() System.out.pri ntln (a=+a+nb=
8、+b); class SubClass exte nds SuperClass int c;SubClass(i nt aa,i nt bb,i nt cc) super(aa,bb);c=cc;class SubSubClass exte nds SubClass int a;SubSubClass(i nt aa,i nt bb,i nt cc) super(aa,bb,cc);a=aa+bb+cc;void show() System.out.pri ntln( a=+a+inb=+b+nc=+c); 9.以下程序的输出结果为 class Pers onpublic Person。Sys
9、tem.out.pri ntln (Pers on);class Stude nt exte nds Personpublid Stude nt()System.out.pri ntl n( Stude nt);class CollegeStude nt exte nds Stude ntpublic CollegeStude nt()System.out.pri ntln (CollegeStude nt);public class Testpublic static void main( Stri ng args)CollegeStude nt cs=new CollegeStude nt
10、();10 .通过键盘输入10个整数,并按输入的倒序输出这10个整数。import java.io.*;public class Reversepublic static void main(String args)int i,n=10;int a=new int10;for (i=0;i=0;i-)System.out.pri nt( ai+);System.out.pri ntl n();11.以下程序的输出结果为 。public class EqualOrNotpublic static void main(String args)B b1= new B(5);B b2=new B(5)
11、;System.out.pri ntln( b1=b2);System.out.pri ntln( b1.equals(b2);class Bint x;B(i nt y)x=y;12 以下程序的输出结果为 class Pare ntvoid prin tMe()System.out.pri ntl n(pare nt);class Child exte nds Pare ntvoid prin tMe()System.out.pri ntln (child);void prin tAll()super.pri ntMe();this.pri ntMe();prin tMe(); bpubli
12、c class Test_thispublic static void main(String args)Child myC=new Child();myC.pri ntAll();13 以下程序的输出结果为 classCrun chervoidcrun ch(int i )System.out.print( “int ” );voidcrun ch(Stri ngs)System.out.print( “String ” );args)public static voidmain( Stri ngCrun cher crun=newCrun cher();charch= h;inti=12;
13、crun.crun ch(ch);System.out.print( “, ” );crun.crun ch(i);14 阅读以下程序:import java.io.*;public class AboutFilepublic static voidmain( Stri ng args)BufferedReader b=new BufferedReader (new InputStreamReader(System.i n);Stri ng s;System.out.flush();try s=b.readL in e();System.out.println(“String is: ” +s
14、);Catch(IOException e) System.out.pri ntln( e.getMessage();publicclassTryCatchFi nallystaticvoid Proc( inttryif(sel=0System.out.pri ntl n( noreturn;else if(运行以上程序,若从键盘输入:java回车贝y输出结果为15 写出以下程序的运行结果。sel )Excepti on ”);sel=1 ) int i=0; int j=4/i;catch(ArithmeticExceptio nSystem.out.pri ntln (Catch cat
15、ch(Excepti onSystem.out.pri ntln (Will fin allySystem.out.pri ntl n(fin ally);static void mai n(Stri ngProc( 0);”);)notbeexecuted);public输出结果为: 15 阅读以下程序,写出输出结果。argsProc( 1);class An imalAn imal() System.out.pri nt(A nimal );public class Dogexte ndsAni malDog()System.out.pri nt(Dog );public static voidmain( Stri ngargs)Dogsn oppy=new Dog(); 输出结果为: 。编程题1、 编写一个类,要求该类实现一个接口,该接口有3个abstract方法:public abstract void f(int x);public abstract void g(i nt x, int y);public abstract double h
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 区块链协议书实验
- 常德吊车租赁协议书电话
- 2025年RISC-VADC控制器技术考核试卷
- 2025初级商业人像摄影师美妆人像高清细节修图考核试卷
- 桥面系分包协议书
- 德国代理酒店协议书
- 白条羊销售协议书
- wifi蓝牙协议书授权
- 签了试读协议书又犯错
- 2025旅游资源保护技术文物修复考核试卷
- 2025年船舶租赁合同协议书模板
- 2025年注册兽医《兽医临床诊疗学》备考题库及答案解析
- 2025年小学五年级数学上学期单元测试专项训练(含答案)
- 护士长月报表1
- 体效应振荡器工作特性和波导管状态
- 向阳小学校园卫生检查量化评分表
- (完整版)形式发票模版(国际件通用)
- 国家开放大学《社区护理学(本)》形考任务1-5参考答案
- 冀教英语七年级上单词及短语
- 平面构成-特异构成
- 眼镜技术试题
评论
0/150
提交评论