Java進階自測:面向對象基礎知識掌握了嗎?
你是否已經參與過Java入門知識的自測?(點這裡:Java編程基礎自測題)
如果得分在80分以上,就來試試這個進階版的自測吧,其中部分考題如下,答案附文後。(線上自測地址:【進階版】Java面向對象編程基礎自測題)
1. 現在有如下一段代碼
將產生哪種結果:
A. Compilation will fail
B. Compilation will succeed and the program will print「0」
C. Compilation will succeed and the program will print「1」
D. Compilation will succeed and the program will print「2」
2. 如要在字元串s(內容為「welcome to mldn !! 」),中,發現字元"t 的位置,應該使用下面哪種方法?
A. mid(2,s);
B. charAt(2);
C. s.indexOf( t );
D. indexOf(s, v );
3. 編譯和運行下面代碼可能會發生什麼?
class Base { private void amethod(int iBase) { System.out.println("Base.amethod"); } } class Over extends Base { public static void main(String args[]) { Over o = new Over(); int iBase = 0 ; o.amethod(iBase) ; } public void amethod(int iOver) { System.out.println("Over.amethod"); } }
A. Compile time error complaining that Base.amethod is private
B. Runntime error complaining that Base.amethod is private
C. Output of Base amethod
D. Output of Over.amethod
4. 現在有如下一段程序
class super { String name ; public super(String name) { this.name = name ; } public void fun1() { System.out.println("this is class super !"+name); } } class sub extends super { public void fun1() { System.out.println("this is class sub !"+name); } } class Test { public static void main(String args[]) { super s = new sub(); } }
運行上面的程序可能會出現的結果?
A. this is class super !
B. this is class sub !
C. 編譯時出錯
D. 運行時出錯
5. 現在有如下一段程序
class Happy { public static void main(String args[]) { float [][] f1 = {,} ; Object oo = f1 ; f1[1] = oo ; System.out.println("Best Wishes "+f1[1]); } }
該程序會出現何種效果?
A.
B. 4.5
C. compilation error in line NO.5
D. exception
6. 在一個類文件中,導入包、類和打包是怎樣的排列順序?
A. package、import、class;
B. class、import、package
C. import、package、class
D. package、class、import
7. 如果你試圖編譯並運行下列代碼時可能會列印輸出什麼?
A. default
B. default , zero
C. error default clause not defined
D. no output displayed
8. 當你編譯下列代碼可能會輸出什麼?
A. Error Variable i may not have been initialized
B. null
C. 1
D. 0
9. 下面代碼會存在什麼問題?
A. 錯誤,void amethod()不是static類型
B. 錯誤,main()方法不正確
C. 錯誤,數組必須導入參數
D. 方法amethod()必須用String類型描述
10. 為Demo類的一個無形式參數無返回值的方法method書寫方法頭,使得使用類名Demo作為前綴就可以調用它,該方法頭的形式為?
A. static void method( )
B. public void method( )
C. final void method( )
D. abstract void method( )
答案:ACDCC ABDAA 你答對了幾道題呢?
更多學習資源,敬請關註:阿里雲大學 - 知乎專欄


※景馳、圖森和小馬智行,連續三家中國自動駕駛公司在美路測獲批
※矽谷有哪些對抗死亡的黑科技企業,它們分別在做什麼?
※中國的超市之王是如何崛起的?
※美國保險創企Sure獲800萬美元A輪融資,首發智能手機保護險
※關於這身紅衣 還有一個故事
TAG:推酷 |
※Perl 面向對象
※Lua 面向對象
※Python入門基礎之面向對象四:運算符重載
※Python3快速入門知識點:面向對象
※面向不同需求的對象存儲系統對比:Ceph與Swift
※在線等!如何用對象能懂的方式解釋面向對象編程?
※面向對象:對方申請同步您的世界,是否授權?
※面向對象:你願意和我一起去尋找 ALL BLUE 嗎?
※Python指南:面向對象程序設計
※做一次面向對象的體操:將 JSON 字元串轉換為嵌套對象的一種方法
※如何評價OPPO面向印度線上市場推出的Realme1?
※面向對象編程,再見!
※面向對象:希望餘生都與您有關
※格芯即將交付Socionext的下一代面向先進車內顯示器應用的圖形控制器
※DeepMind等機構提出「圖網路」:面向關係推理
※「火鍋問答」是啥?面向自然語言和多步推理問題,新型問答數據集HotpotQA面世
※雲知聲黃偉:面向AIoT時代,我們為什麼必須要做晶元?
※華擎推出Phantom Gaming系列A卡,面向礦工的顯卡?
※資源 |「火鍋問答」是啥?面向自然語言和多步推理問題,新型問答數據集HotpotQA面世
※HTC Vive Focus會不會面向全球發售?要看國內賣得怎麼樣