




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、1、阅读以下程序,输出结果为 。class Q1public static void main(String args )double d=1.23;Dec dec=new Dec( );dec.decrement(d);System.out.println(d);classs Decpublic void decrement(double decMe)decMe = decMe 0.1;2、以下程序段的输出结果为 。class Cruncher void crunch( int i ) System.out.println(“int version”); void crunch(String
2、 s) System.out.println(“String version”); public static void main(String args ) Crunchercrun=new Cruncher ( ); char ch=p; crun.crunch(ch); 3、阅读以下程序段:class Parentvoid printMe()System.out.println(“pt”);class Child extends Parentvoid printMe()System.out.print (“cd”);void printAll()super.printMe();this.
3、printMe();printMe();public class Test_thispublic static void main(String args )Child myC=new Child();myC.printAll();输出结果为 。4、已有Bird类的定义如下:package abcde;public class Bird protected static int referenceCount=0; public Bird() referenceCount+; protected void fly() static int getReCount() return referenc
4、eCount; 有类Nightingale的定义如下,请写出它的输出结果 。package singers;class Nightingale extends abcde.Bird Nightingale( ) referenceCount+;public static void main( String args ) System.out.print(“Before:”+referenceCount); Nightingale florence=new Nightingale( ); System.out.println(“ After:”+referenceCount); florence
5、.fly( );5、以下程序段的输出结果为 。public class testpublic static void main(String args ) StringBuffer s = new StringBuffer("Hello"); s.append("there"); System.out.println(s); String pf = s.substring(0, s.length(); System.out.println(pf.equals("Hellothere"); 6、以下程序段的输出结果为 。class Pe
6、rson public Person() System.out.println("hi!"); public Person(String s) this(); System.out.println("I am "+s); public class Who extends Person public Who() this("I am Tony"); public Who(String s) super(s); System.out.println("How do you do?"); public static vo
7、id main(String args) Who w = new Who("Tom"); 7下面是一个类的定义。class _ / 定义名为MyClass的类 _ int var=666; static int getvar() return var; 8以下程序的输出结果为 。public class abc public static void main(String args ) SubSubClass x = new SubSubClass(10 , 20 , 30); x.show(); class SuperClass int a,b; SuperClass(i
8、nt aa , int bb) a=aa; b=bb; void show( ) System.out.println("a="+a+"nb="+b); 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 sh
9、ow() System.out.println("a="+a+"nb="+b+"nc="+c); 9以下程序的输出结果为 。class Person public Person() System.out.println("Person"); class Student extends Person publid Student() System.out.println("Student"); class CollegeStudent extends Student public CollegeS
10、tudent() System.out.println("CollegeStudent"); public class Test public static void main(String args) CollegeStudent cs=new CollegeStudent(); 10通过键盘输入10个整数,并按输入的倒序输出这10个整数。import java.io.*;public class Reverse public static void main(String args) int i,n=10; int a=new int10; for (i=0;i<
11、n;i+) try BufferedReader br=new BufferedReader( ); ai=Integer.parseInt( ); /输入一个整数 catch(IOException e); for(i=n-1;i>=0;i-) System.out.print(ai+" "); System.out.println(); 11以下程序的输出结果为 。public class EqualOrNot public static void main(String args) B b1=new B(5); B b2=new B(5); System.out
12、.println(b1=b2); System.out.println(b1.equals(b2); class B int x; B(int y) x=y; 12以下程序的输出结果为 。class Parent void printMe() System.out.println("parent"); class Child extends Parent void printMe() System.out.println("child"); void printAll() super.printMe(); this.printMe(); printMe(
13、); bpublic class Test_this public static void main(String args) Child myC=new Child(); myC.printAll(); 13以下程序的输出结果为 。class Crunchervoid crunch( int
14、 i ) System.out.print(“int”); void crunch(String s) System.out.print(“String”); public static void main(String args )Cruncher crun=new Cruncher
15、160;( );char ch=h;int i=12;crun.crunch(ch); System.out.print(“,”);crun.crunch(i); 14阅读以下程序:import java.io.*;public class AboutFile public static void main(
16、String args) BufferedReader b=new BufferedReader (new InputStreamReader(System.in); String s; System.out.flush();
17、0; try s=b.readLine(); System.out.println(“String is:”+s); Catch(IOException e) System.out.println(e.getMessage(); 运行以上程序,若从键盘输入: java<回车>则输出结果为 。15写出以下程序的运行结果。public
18、 class TryCatchFinally static void Proc( int sel ) try if( sel=0 )System.out.println("
19、;no Exception "); return; else if( sel=1 ) int i=0; int j=4/i;
20、0; catch( ArithmeticException e ) System.out.println("Catch "); catch( Exception e ) System.out.p
21、rintln("Will not be executed"); finally System.out.println("finally"); public static void main( String args ) Proc( 0 ); Proc( 1 ); 输出结果为: 。15阅读以下程序,写出输出结果。class Animal Animal() System.out.print ("Animal
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 马鞍山职业技术学院《材料力学C》2023-2024学年第二学期期末试卷
- 大连工业大学艺术与信息工程学院《汇编语言和计算机组成原理》2023-2024学年第二学期期末试卷
- 北京师范大学-香港浸会大学联合国际学院《嵌入式程序设计》2023-2024学年第二学期期末试卷
- 辽宁体育运动职业技术学院《电力企业会计》2023-2024学年第二学期期末试卷
- 福建师范大学协和学院《房地产营销策划》2023-2024学年第二学期期末试卷
- 黑龙江工程学院昆仑旅游学院《弹性力学及有限元》2023-2024学年第二学期期末试卷
- 天津大学《高级园艺植物遗传育种》2023-2024学年第二学期期末试卷
- 心理健康课嫉妒的课件
- 大班心理健康教育:我勇敢了
- 灯饰设计与制作
- 《采煤学》教材笔记
- 汉字介绍课件
- 2025年熔化焊接与热切割作业证理论考试试题(1000题)附答案
- 2025年度继续教育公需科目(AI工具学习与运用)考试试题(满分版含答案)
- 广东广东省青少年发展基金会招聘笔试历年参考题库附带答案详解
- 跨学科实践“制作‘水火箭’”(教学设计)-2024-2025学年八年级物理下学期项目化课程案例
- 2025新生儿高胆红素血症诊治指南解读课件
- 车抵押车合同协议
- 2025年FRM金融风险管理师考试金融风险管理法规试卷
- 幼儿园大班科学课程《奇妙的彩虹》教学方案
- 农药销售策略优化路径-全面剖析
评论
0/150
提交评论