1Z0-829 Utilizing Java Object-Oriented Approach Practice Question
Exhibit
abstract class Animal {
abstract void sound();
}
interface Pet {
default void play() { System.out.println("Playing"); }
}
class Dog extends Animal implements Pet {
void sound() { System.out.println("Bark"); }
}
public class Test {
public static void main(String[] args) {
Dog d = new Dog();
d.sound();
d.play();
}
}Refer to the exhibit. What is the result?
⚠ Common exam trap
A common mix-up: candidates think the `play()` method must be overridden in `Dog` to be called, or that the output would be only 'Bark' because they overlook the inherited method call, leading them to choose option D.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Bark Playing
The code compiles and runs without error. The object referenced by a1 is a Dog instance. The code first calls the bark() method, which prints 'Bark' (defined in Dog). Then it calls the play() method, which is not overridden in Dog, so it invokes the inherited play() method from Animal, printing 'Playing'. Therefore, the output is 'Bark' followed by 'Playing', which matches option B.
Go deeper
Related to this question
About these practice questions
One of 513 original 1Z0-829 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This 1Z0-829 practice question is part of Courseiva's free Oracle certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the 1Z0-829 exam.