nerdexam
Oracle

1Z0-851 · Question #249

Given: class TestA { public void start() { System.out.println("TestA"); } } public class TestB extends TestA { public void start() { System.out.println("TestB"); } public static void main(String[]…

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

Question

Given: class TestA { public void start() { System.out.println("TestA"); } } public class TestB extends TestA { public void start() { System.out.println("TestB"); } public static void main(String[] args) { ((TestA)new TestB()).start(); } } What is the result?

Options

  • ATestA
  • BTestB
  • CCompilation fails.
  • DAn exception is thrown at runtime.

How the community answered

(40 responses)
  • A
    13% (5)
  • B
    80% (32)
  • C
    5% (2)
  • D
    3% (1)

Community Discussion

No community discussion yet for this question.

Full 1Z0-851 Practice