| preferred AP College board partner for AP classes
AP Computer Science A/Unit 9: Inheritance
Start Practice TestPractice Test
About Exam
medium Solved by 2 students
Java Subclass Constructor Implementation
< Prev
Next >

Consider the following class definitions.

public class Employee {
    private String name;
    private double salary;
    public Employee() {
        name = "";
        salary = 0.0;
    }
    public Employee(String n) {
        name = n;
        salary = 0.0;
    }
    public Employee(String n, double s) {
        name = n;
        salary = s;
    }
    // Other methods not shown
}

public class Manager extends Employee {
    private double bonus;
    public Manager(String n, double s, double b) {
        /* implementation not shown */
    }
    // Other methods not shown
}

Which of the following code segments, if substituted for /* implementation not shown */, provides a correct implementation for the Manager constructor?

I. super(n, s); this.bonus = b;

II. super(); name = n; salary = s; bonus = b;

III. super(n); this.salary = s; this.bonus = b;

A

I only

B

II only

C

I, II, and III

D

I and III only

Hint
Did You Know?
Explain Why
Explain All Answers
Check Answer
Show Correct Answer
Report Question

Question Leaderboard

Not enough data yet to show leaderboard.

No comments yet. Be the first to comment!

AI Tutor

How can I help?

APFIVE © 2020.
Email: apfive@apfive.org|Privacy Policy