abstract 相關(guān)問題

2018-07-03 14:41 更新

題目一

什么是抽象類

  1. A class with no methods
  2. A class with no concrete subclasses
  3. A class with at least one undefiend message
  4. None of above

答案是 4 我們是可以定義一個抽象空類的

  1. abstract class emptyAb {}

題目二

  1. abstract class Base{
  2. abstract public void myfunc();
  3. }
  4. public class Abs extends Base{
  5. public static void main(String argv[]){
  6. Abs a = new Abs();
  7. a.amethod();
  8. }
  9. public void amethod(){
  10. System.out.println("A method");
  11. }
  12. }

運行的結(jié)果

  1. 輸出 A method
  2. The code will compile but complain at run time
  3. The compiler will complain errors in Abs class

答案是 3

以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號