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)- A13% (5)
- B80% (32)
- C5% (2)
- D3% (1)
Community Discussion
No community discussion yet for this question.