Are you taking CLEP classes? Try clep.ai
| preferred AP College board partner for AP classes
medium Solved by 1 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, II, and III

B

II only

C

I only

D

I and III only

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

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|FAQ