Courseiva
Object-Oriented ProgrammingeasyMultiple ChoiceObjective-mapped

1Z0-811 Object-Oriented Programming Practice Question

Exhibit

Refer to the exhibit.
public class Employee {
    private String name;
    public Employee(String name) { this.name = name; }
    public String getName() { return name; }
}
public class Manager extends Employee {
    private int teamSize;
    public Manager(String name, int teamSize) {
        super(name);
        this.teamSize = teamSize;
    }
}

What is the output of: System.out.println(new Manager("Alice", 5).getName());

⚠ Common exam trap

Oracle often tests whether candidates understand that a subclass constructor can pass arguments to a superclass constructor, and that inherited methods like getName() work correctly without additional overrides, causing some to mistakenly think the code fails or returns null.

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

Alice

The code creates a new Manager object with the name "Alice" and a level of 5, then calls getName() on it. Assuming Manager extends a class (likely Employee) that has a constructor setting the name field via super(name), getName() returns the stored name "Alice". The code compiles and runs without exception, printing "Alice".

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • Runtime exception

    Why it's wrong here

    No exception.

  • Compilation fails

    Why it's wrong here

    Code compiles; Employee has a no-arg constructor? No, but Manager calls super(name) explicitly.

  • Alice

    Why this is correct

    Correct; name is set via super constructor.

  • null

    Why it's wrong here

    super(name) sets name to Alice.

About these practice questions

Courseiva writes every 1Z0-811 question from scratch — 481 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This 1Z0-811 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-811 exam.