多做题,通过考试没问题!

Java认证考试

睦霖题库>其他计算机考试>Java认证考试

What will be written to the standard output when the following program is run?()   class Base {  int i;  Base() {   add(1);   }   void add(int v) {  i += v;  }   void print() {  System.out.println(i);  }   }   class Extension extends Base {  Extension() {  add(2);  }   void add(int v) {  i += v*2;  }  }   public class Qd073 {   public static void main(String args[]) {  bogo(new Extension());  }   static void bogo(Base b) {  b.add(8);  b.print();   }   }  

  • A、9
  • B、18
  • C、20
  • D、21
  • E、22
正确答案:E
答案解析:
进入题库查看解析

微信扫一扫手机做题