| preferred AP College board partner for AP classes
Login
 
Register
AP Computer Science A/Unit 9: Inheritance
Start Practice Test
Share
Java Subclass Constructor Implementation
< Prev
Next >

Which is a correct implementation of the constructor in the Manager class?
Refer to 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 is a correct implementation of the constructor in the Manager class?

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

II only

B

I, II, and III

C

I only

D

I and III only

Check Answer
APFIVE © 2020.
Email: [email protected]|Privacy Policy