Question
In the following, we used inheritance to define relationships between three classes. public class Employee { protected int age; }; public class SalariedEmployee extends Employee
In the following, we used inheritance to define relationships between three classes. public class Employee { protected int age; }; public class SalariedEmployee extends Employee { public int ID; };
public class HourlyEmployee extends Employee { private int salary; }; Does this relationship correctly reflect the inheritance behavior ? If not, what is wrong with it? If Yes, explain.
What is the relationship between class SalariedEmployee and class HourlyEmployee ?Explain.
Can we access the variable age from class SalariedEmployee ? Explain.
Can we access the variable ID from class Employee ? Explain.
Can we access the variable salary from class HourlyEmployee ? Explain.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started