




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領
文檔簡介
1、1、閱讀以下程序,輸出結(jié)果為 。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、以下程序段的輸出結(jié)果為 。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();輸出結(jié)果為 。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的定義如下,請寫出它的輸出結(jié)果 。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、以下程序段的輸出結(jié)果為 。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、以下程序段的輸出結(jié)果為 。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以下程序的輸出結(jié)果為 。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以下程序的輸出結(jié)果為 。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個整數(shù),并按輸入的倒序輸出這10個整數(shù)。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( ); /輸入一個整數(shù) catch(IOException e); for(i=n-1;i>=0;i-) System.out.print(ai+" "); System.out.println(); 11以下程序的輸出結(jié)果為 。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以下程序的輸出結(jié)果為 。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以下程序的輸出結(jié)果為 。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<回車>則輸出結(jié)果為 。15寫出以下程序的運行結(jié)果。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 ); 輸出結(jié)果為: 。15閱讀以下程序,寫出輸出結(jié)果。class Animal Animal() System.out.print ("Animal
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 什補充協(xié)議與主合同案例
- 有害垃圾合同協(xié)議
- 創(chuàng)業(yè)合伙合同協(xié)議
- 外墻清洗合同協(xié)議
- 學位房協(xié)議合同
- 建筑安全員合同協(xié)議書
- 冷庫采購協(xié)議合同
- 勞動合同培訓補充協(xié)議
- 合同背面的協(xié)議
- 過戶房子協(xié)議合同
- GB/T 42716-2023電化學儲能電站建模導則
- 技術(shù)的本質(zhì)(經(jīng)典版)
- 新媒體運營PPT全套完整教學教學
- 嚴重精神障礙患者管理服務規(guī)范標準
- 水利工程管理單位編制定員試行標準(slj-705-81)
- 主動脈夾層外科治療及圍術(shù)期血壓管理
- D500-D505 2016年合訂本防雷與接地圖集
- 小學勞動教育二下第三單元 1 《水培綠蘿》課件
- 雙重預防體系基礎知識考試試題及答案
- 工會經(jīng)費收支管理培訓
- 初一英語情態(tài)動詞練習題含答案
評論
0/150
提交評論