1. class A { 2. public String toString () { 3. return “4”; 4. } 5. } 6. class B extends A { 7. public String toString () { 8. return super.toString() + “3”; 9. } 10. } 11. public class Test { 12. public static void main(String[]args) { 13. System.out.printIn(new B()); 14. } 15. } What is the result?()
- A、 Compilation succeeds and 4 is printed.
- B、 Compilation succeeds and 43 is printed.
- C、 An error on line 9 causes compilation to fail.
- D、 An error on line 14 causes compilation to fail.
- E、 Compilation succeeds but an exception is thrown at line 9.
正确答案:B
答案解析:有
微信扫一扫手机做题