This 1Z0-829 practice question tests your understanding of utilizing java object-oriented approach. Read the scenario carefully and evaluate each option against the stated constraints before committing to an answer. A key principle to apply: method Overriding. Once you have made your selection, read the full explanation to reinforce the concept and understand why each distractor is designed to mislead on exam day.
Exhibit
Refer to the exhibit.
public class Main {
public static void main(String[] args) {
System.out.println("Hello");
}
}
And the command:
$ javac Main.java
$ java Main
Output:
Hello
Now consider this class in another file:
public class Sub extends Main {
public static void main(String[] args) {
System.out.println("World");
}
}
Compiled and run:
$ java Sub
What is the output?
Refer to the exhibit. Two Java classes are defined as shown. What is the output when the Sub class is executed?
Exhibit
Refer to the exhibit.
public class Main {
public static void main(String[] args) {
System.out.println("Hello");
}
}
And the command:
$ javac Main.java
$ java Main
Output:
Hello
Now consider this class in another file:
public class Sub extends Main {
public static void main(String[] args) {
System.out.println("World");
}
}
Compiled and run:
$ java Sub
What is the output?
A
HelloWorld
Why wrong: Only Sub's main method runs, not both.
B
World
Sub's main method is executed, printing 'World'.
C
Hello
Why wrong: Sub's main method does not invoke Main's main; it prints 'World'.
D
No output (compilation error)
Why wrong: Both classes compile and run without error.
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
World
Option B is correct because the Sub class overrides the print() method from Super and does not call super.print(). Therefore, when Sub's print() is executed, it only prints "World" without printing "Hello". The output is simply "World".
Key principle: Method Overriding
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
✗
HelloWorld
Why it's wrong here
Only Sub's main method runs, not both.
✓
World
Why this is correct
Sub's main method is executed, printing 'World'.
Related concept
Method Overriding
✗
Hello
Why it's wrong here
Sub's main method does not invoke Main's main; it prints 'World'.
✗
No output (compilation error)
Why it's wrong here
Both classes compile and run without error.
Common exam traps
Common exam trap: answer the scenario, not the keyword
Oracle often tests whether candidates understand that an overridden method in a subclass does not automatically execute the superclass version unless explicitly called with super.method(), leading many to mistakenly think the superclass method runs first by default.
Detailed technical explanation
How to think about this question
In Java, method overriding allows a subclass to provide a specific implementation of a method defined in its superclass. The @Override annotation (optional) helps catch errors at compile time. When a subclass method does not call super.method(), the superclass implementation is completely replaced. In this scenario, the Sub class's print() method does not invoke super.print(), so only its own implementation runs, outputting "World". This is a common pattern when a subclass wants to completely replace behavior rather than extend it.
KKey Concepts to Remember
Method Overriding
super Keyword
TExam Day Tips
→Watch for words such as best, first, most likely and least administrative effort.
→Review why wrong options are wrong, not only why the correct option is correct.
Key takeaway
Method Overriding
Real-world example
How this comes up in practice
A practitioner preparing for the 1Z0-829 exam encounters this exact type of scenario on the job. The correct answer here is not the most general option — it is the best answer for the specific constraint described. Method Overriding Real exam questions reward reading the full scenario before eliminating options, because the constraint defines which answer fits.
What to study next
Got this wrong? Here's your next step.
Review method Overriding, then practise related 1Z0-829 questions on the same topic to reinforce the concept.
The correct answer is: World — Option B is correct because the Sub class overrides the print() method from Super and does not call super.print(). Therefore, when Sub's print() is executed, it only prints "World" without printing "Hello". The output is simply "World".
What should I do if I get this 1Z0-829 question wrong?
Review method Overriding, then practise related 1Z0-829 questions on the same topic to reinforce the concept.
What is the key concept behind this question?
Method Overriding
About these practice questions
Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →
Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.
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.
Question Discussion
Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.
Sign in to join the discussion.