Java Subclass Constructor Implementation
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
Question Leaderboard
Not enough data yet to show leaderboard.
APFIVE