Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Trace the following code to determine what will be outputted when EmployeeProcessor is run: public class Employee { protected double salary; public double getSalary() {

Trace the following code to determine what will be outputted when EmployeeProcessor is run:

public class Employee {

protected double salary; public double getSalary() { return salary; } public void setSalary(double salary) { this.salary = salary; } }

class FullTimeEmployee extends Employee { private double bonus; public double getBonus() { return bonus; }

public void setBonus(double bonus) { this.bonus=bonus; }

@Override public double getSalary() { return salary + bonus; } }

class PartTimeEmployee extends Employee { @Override public double getSalary() { return salary / 2; }

public class EmployeeProcessor { public static void main(String[] args) { Employee justAnEmployee = new Employee(); justAnEmployee.setSalary(10000.0); FullTimeEmployee fulltimeemployee = new FullTimeEmployee(); fulltimeemployee.setSalary(10000.0); fulltimeemployee.setSalary(2000.0); PartTimeEmployee parttimeemployee = new PartTimeEmployee(); parttimeemployee.setSalary(10000.0); System.out.print("1. My salary is: " + justAnEmployee.getSalary()); System.out.print("2. My salary is: " + fulltimeemployee.getSalary()); System.out.print("3. My salary is: " + parttimeemployee.getSalary()); } } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beyond Big Data Using Social MDM To Drive Deep Customer Insight

Authors: Martin Oberhofer, Eberhard Hechler

1st Edition

0133509796, 9780133509793

Students also viewed these Databases questions

Question

How many Tables Will Base HCMSs typically have? Why?

Answered: 1 week ago

Question

What is the process of normalization?

Answered: 1 week ago