nerdexam
Oracle

1Z0-851 · Question #51

Given: 11. static class A { 12. void process() throws Exception { throw new Exception(); } 13. } 14. static class B extends A { 15. void process() { System.out.println("B"); } 16. } 17. public…

The correct answer is A. B. See the full explanation below for the reasoning.

Question

Given: 11. static class A { 12. void process() throws Exception { throw new Exception(); } 13. } 14. static class B extends A { 15. void process() { System.out.println("B"); } 16. } 17. public static void main(String[] args) { 18. new B().process(); 19. } What is the result?

Options

  • AB
  • BThe code runs with no output.
  • CCompilation fails because of an error in line 12.
  • DCompilation fails because of an error in line 15.
  • ECompilation fails because of an error in line 18.

How the community answered

(39 responses)
  • A
    69% (27)
  • B
    3% (1)
  • C
    15% (6)
  • D
    5% (2)
  • E
    8% (3)

Community Discussion

No community discussion yet for this question.

Full 1Z0-851 Practice