Oracle
1Z0-819 · Question #143
1Z0-819 Question #143: Real Exam Question with Answer & Explanation
Sign in or unlock 1Z0-819 to reveal the answer and full explanation for question #143. The question stem and answer options stay visible for context.
Question
Given:
public class Test {
public static void main(String[] args) {
AnotherClass ac = new AnotherClass();
SomeClass sc = new AnotherClass();
ac = sc;
sc.methodA();
ac.methodA();
}
}
class SomeClass {
public void methodA() {
System.out.println("SomeClass#methodA() ");
}
}
class AnotherClass extends SomeClass {
public void methodA() {
System.out.println("AnotherClass#methodA() ");
}
}
What is the result?
Options
- AA ClassCastException is thrown at runtime.
- BAnotherClass#methodA()AnotherClass#methodA()
- CThe compilation fails.
- DSomeClass#methodA()AnotherClass#methodA()
- EAnotherClass#methodA()SomeClass#methodA()
- FSomeClass#methodA()SomeClass#methodA()
Unlock 1Z0-819 to see the answer
You've previewed enough free 1Z0-819 questions. Unlock 1Z0-819 for full answers, explanations, the timed quiz mode, progress tracking, and the master PDF. Question stem and options stay visible so you can still see what's on the exam.