10. abstract public class Employee {11. protected abstract double getSalesAmount();12. public double getCommision() {13. return getSalesAmount() * 0.15;14. }15. }16. class Sales extends Employee {17. 18. }Which method, inserted at line 17, correctly complete the Sales class?
Question
10. abstract public class Employee {11. protected abstract double getSalesAmount();12. public double getCommision() {13. return getSalesAmount() * 0.15;14. }15. }16. class Sales extends Employee {17. 18. }Which method, inserted at line 17, correctly complete the Sales class?
Solution
To correctly complete the Sales class, you need to provide an implementation for the abstract method getSalesAmount() from the Employee class. Here is how you can do it:
@Override
protected double getSalesAmount() {
// return the sales amount
// this is just a placeholder, replace it with actual logic
return 0;
}
So, the complete Sales class will look like this:
class Sales extends Employee {
@Override
protected double getSalesAmount() {
// return the sales amount
// this is just a placeholder, replace it with actual logic
return 0;
}
}
Please note that the actual logic for calculating the sales amount should replace the return 0; line. This logic will depend on how you are tracking sales in your application.
Similar Questions
abstract public class Employee {11. protected abstract double getSalesAmount();12. public double getCommision() {13. return getSalesAmount() * 0.15;14. }15. }16. class Sales extends Employee {17. 18. }
Given:1. public class Employee {2. String name;3. double baseSalary;4. Employee(String name, double baseSalary) {5. this.name = name;6. this.baseSalary = baseSalary;7. }8. }And:11. public class Salesperson extends Employee {12. double commission;13. public Salesperson(String name, double baseSalary,14. double commission) {15. // insert code here16. }17. } Which code, inserted at line 17, completes the Salesperson constructor?Select one:a.this.commission = commission;b.this.commission = commission;super();c.this.commission = commission;super(name, baseSalary);d.super();commission = commission;e.super();this.commission =commission;f.super(name, baseSalary);this.commission = commission;
Observe the below code. You have a class InsurancePolicy and another class VehicleInsurancePolicy that inherits InsurancePolicy.InsurancePolicy.javapublic class InsurancePolicy { private int policyNumber; private String holderName; private double amount; double calculateBonusAmount(){ //some logic return 0; } }VehicleInsurancePolicy.javaclass VehicleInsurancePolicy extends InsurancePolicy { private String vehicleNumber; private int noOfMonths; double calculateBonusAmount(){ //some logic return 0; }}Which access specifier can be given to the overridden method calculateBonusAmount.
10. class FourWheeler {11. blank void display() { }12. }13. class Car extends FourWheeler {14. blank void display() { }15. }Which method at line 14, will correctly complete class Car?protected private
Choose the correct statement about the following code: 1: interface HasExoskeleton { 2: abstract int getNumberOfSections(); 3: } 4: abstract class Insect implements HasExoskeleton { 5: abstract int getNumberOfLegs(); 6: } 7: public class Beetle extends Insect { 8: int getNumberOfLegs() { return 6; } 9: } *1 pointA. It compiles and runs without issue.B. The code will not compile because of line 2.C. The code will not compile because of line 4.D. The code will not compile because of line 7.E. It compiles but throws an exception at runtime.
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.