版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
1、第七章繼承多態(tài)一、選擇題:1、分析: class A A() class B extends A /系統(tǒng)自動生成的構造方法和類的訪問權限一樣 哪兩種說法是正確的? ()A:類B的構造方法是public的. B:類B的構造方法包含對this()的調用.C:類B的構造方法沒有參數(shù). D:類B的構造方法包含對super()的調用.2、運行結果是:() class Base Base() System.out.print(Base); public class Alpha extends Base public static void main( String args ) new Alpha();
2、new Base(); A: BaseB: BaseBaseC: 編譯失敗. D: 沒有輸出.E: 運行時異常.3. 程序的運行結果是?()A: 編譯失敗.B: hello from aC: hello from bD: hello from b E: hello from ahello from a hello from b4. 運行結果是:() class TestSuper TestSuper(int i) class TestSub extends TestSuper class TestAll public static void main (String args) new Tes
3、tSub(); A: 編譯失敗.B: 程序運行沒有異常.C: 第7行拋出異常.D: 第2行拋出異常.5. 程序的運行結果是?()A: 0B: 1C: 2D: 編譯失敗.6. 對于語句B is a D 和 B has a C,一下哪兩種說法是正確的? ()A:D是B.B:B是D.C:D是C.D:B是C.E:D繼承 B.F:B 繼承D.7. 運行結果是?()A: 1B: 2C: 第8行編譯失敗.D: 第14行編譯失敗.8. 分析: public class ConstOver public ConstOver(int x, int y, int z) 哪兩個是對ConstOver 的構造方法的重載
4、? ()A:ConstOver() B:protected int ConstOver() C:private ConstOver(int z, int y, byte x) D:public Object ConstOver(int x, int y, int z) E:public void ConstOver(byte x, byte y, byte z) 9. 運行結果是?()A: 4,4B: 4,5C: 5,4D: 5,5E: 編譯失敗.10. 分析: public class X public X aMethod() return this; 1) public class Y e
5、xtends X 2) 3) 在第2行可以插入哪兩項? ()A:public void aMethod() B:private void aMethod() C:public void aMethod(String s) D:private Y aMethod() return null; E:public X aMethod() return new Y(); 11. 運行結果是?()A: 4,4B: 4,5C: 5,4D: 5,5E: 編譯失敗.12. 以下哪兩個重載了方法setVar()? () public class MethodOver public void setVar(int
6、 a, int b, float c) A:private void setVar(int a, float c, int b) B:public int setVar(int a, float c, int b) return a;C:protected void setVar(int a, int b, float c) D:public int setVar(int a, int b, float c) return a;E:protected float setVar(int a, int b, float c) return c;13. 分析: 1) class BaseClass
7、2) private float x = 1.0f; 3) protected void setVar(float f) x = f; 4) 5) class SubClass extends BaseClass 6) private float x = 2.0f; 7) / insert code here 8) 在第7行插入哪兩個覆蓋了方法setVar()? ()A:void setVar(float f) x = f; B:public void setVar(int f) x = f; C:public void setVar(float f) x = f; D:public doub
8、le setVar(float f) return f; E:public final void setVar(float f) x = f; F:protected float setVar() x = 3.0f; return 3.0f; 14. 運行結果是?()A: 1B: 2C: 運行時異常.D: 第8行編譯錯誤.E: 第14行編譯錯誤.15. 分析: class A protected int method1(int a, int b) return 0; 在A的子類中,以下哪兩個方法是合法的? ()A:public int method1(int a, int b) return
9、0; B:private int method1(int a, long b) return 0; C:private int method1(int a, int b) return 0; D:public short method1(int a, int b) return 0; E:static protected int method1(int a, int b) return 0; 16. 分析: 1) public abstract class Test 2) public abstract void methodA(); 3) 4) public abstract void me
10、thodB()5) 6) System.out.println(Hello); 7) 8) 哪兩種改法,可以使程序通過編譯? ()A:給方法methodA()加方法體C:在Test的聲明中去掉abstractB:用;替換第5-7行D:在方法methodA()的聲明中去掉abstractE: 在方法methodB()的聲明中去掉abstract17. 運行結果是:() 1) abstract class AbstractIt 2) abstract float getFloat(); 3) 4) public class AbstractTest extends AbstractIt 5) pr
11、ivate float f1 = 1.0f; 6) private float getFloat() return f1; 7) A: 編譯成功.B: 運行時異常.C: 第2行編譯失敗.D: 第6行編譯失敗.18. 在接口中哪兩個方法的聲明是合法的? ()A:void method1();B:public void method2();C:static public void method5();D:protected void method3();E:final public void method4();19. 分析: 1) public interface Foo 2) int k =
12、4; 3) 哪三項與第2行等價? ()A:final int k = 4;B:public int k = 4;C:static int k = 4;D:abstract int k = 4;E:volatile int k = 4;F:protected int k = 4;20. 分析: interface Inter class A implements Inter class B extends A B() A arr = new A10; boolean b1 = this instanceof Inter; boolean b2 = arr instanceof Object; S
13、ystem.out.println(b1 = + b1 + , b2 = + b2); 創(chuàng)建B的對象時會輸出?()A: 編譯失敗.B: b1 = true, b2 = trueC: b1 = true, b2 = falseD: b1 = false, b2 = trueE: b1 = false, b2 = false21. 哪一個能通過編譯?()A: new Animal().soundOff();B: Lion l = Alpha1.get(meat eater);C: Elephant e = new Alpha1();D: new Alpha1().get(veggie).sound
14、Off();22. 分析: class Passenger class Engine interface TransportVehicle void loadPassengers(); interface Helicopter extends TransportVehicle int flyIt( String direction ); abstract class JetStream implements Helicopter 哪種說法是正確的?()A: TransportVehicle has a Passenger.B: 類Engine在類JetStream中.C: 接口Transpor
15、tVehicle可以形成多態(tài)的基礎.D: 繼承JetStream的非抽象類可以隨意聲明方法loadPassengers().23. 哪三個是is a 關系? ()A:public class X B:public interface Shape public class Y extends X public interface Rectangle extends Shape C:public interface Color D:public class Species public class Shape private Color color; public class Animal pri
16、vate Species species; E:public class Person F:interface Component public class Employee class Container implements Component public Employee(Person person) private Component children;24. 運行結果是:() public interface Test int frood = 42; class TestImpl implements Test private static int frood; public st
17、atic void main(String args) System.out.println(+frood); A: 0B: 1C: 42D: 43E: 編譯失敗.F: 運行時異常.25. 運行結果是?()A: 5B: 10C: 編譯失敗.D: 運行時異常.26. 運行結果是:() 1) public class Test 2) public static void main(String args) 3) class Foo 4) public int i = 3; 5) 6) Object o = (Object)new Foo(); 7) Foo foo = (Foo)o; 8) Sys
18、tem.out.println(i = + foo.i); 9) 10) A: i = 3C: 第6行拋出ClassCastException異常.B: 編譯失敗.D: 第7行拋出ClassCastException異常.27. 分析: String s = abcde; Object ob = (Object)s; if (ob.equals(s) System.out.println(AAAA); else System.out.println(BBBB); if (s.equals(ob) System.out.println(CCCC); else System.out.println(DDDD); 輸出哪
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 藍色科技風產品發(fā)布會
- 人教版九年級歷史上冊全套教案
- 五年級上冊音樂全冊教案
- 2024屆山東省寧陽十一中重點中學中考英語最后沖刺模擬試卷含答案
- 2023年農業(yè)糧食安全分析評估報告
- 2024年新型高效飼料及添加劑相關公司行業(yè)營銷方案
- 2024年中高壓陰極電容鋁箔行業(yè)營銷策略方案
- 國電系統(tǒng)-安徽省-2023年《信息安規(guī)》科目 單選題+多選題+判斷題+簡答題真題沖刺卷下半年B卷
- 2024年高速型數(shù)控銑床或數(shù)控仿形銑床相關公司行業(yè)營銷方案
- 防洪工程實施方案
- 全新產品總代理合同范本2024年
- 2024年新北師大版七年級上冊數(shù)學教學課件 第一章 豐富的圖形世界 1 生活中的立體圖形 第1課時 認識生活中的立體圖形
- 2024-2030年中國水楊醛產業(yè)應用領域規(guī)模分析及投資前景調研研究報告
- 2024精麻藥品培訓知識試題庫及答案(完整版)
- 2024-2030年消防維保行業(yè)市場發(fā)展分析與發(fā)展前景及投資戰(zhàn)略研究報告
- 2021年中國農業(yè)銀行招聘筆試真題及詳解
- 2024年度中國廣電山東網絡限公司招聘(高頻重點提升專題訓練)共500題附帶答案詳解
- 光伏發(fā)電用電過戶協(xié)議
- 標準作文稿紙模板(A4紙)
- 江西省第一屆職業(yè)技能大賽分賽場項目技術文件(世賽選拔)全媒體運營師
- 房屋大修合同書
評論
0/150
提交評論