Oracle
1Z0-829 · Question #14
1Z0-829 Question #14: Real Exam Question with Answer & Explanation
Sign in or unlock 1Z0-829 to reveal the answer and full explanation for question #14. The question stem and answer options stay visible for context.
Java Object-Oriented Approach
Question
Given:
class A { public void mA() {System.out.println("mA");}}
class B extends A {public void mB() {System.out.println("mB");}}
class C extends B {public void mC() {System.out.println("mC");}}
public class App {
public static void main(String[] args) {
A bObj = new B();
A cObj = new C();
if (cObj instanceof B v) {
v.mB();
} else {
cObj.mA();
}
}
}
What is the result?
Options
- AMb
- BMC
- CMb
- DMA
- EmA
Unlock 1Z0-829 to see the answer
You've previewed enough free 1Z0-829 questions. Unlock 1Z0-829 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.
Topics
#Pattern Matching#instanceof#Inheritance#Polymorphism