Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a JAVA code to implement the following: 1. Create a super class named Human, that has the following members: (.25 Point) a private String
Write a JAVA code to implement the following:
1. Create a super class named Human, that has the following members: (.25 Point)
a private String attribute name (.25 Point)
constructor to initialize the attribute name. (.25 Point)
set method to change the values of name. (.25 Point)
get method to return the values of name. (.25 Point)
override method toString to print the value of name. (.5 Point)
2. Create a sub class named Employee that,
inherits from superclass Human (.5 Point)
has a private attribute ID (.25 Point)
constructor to initialize the attributes name
(via superclass constructor) and ID. (0.5 Point)
3. Write a Test class that has the main method:
Declare a reference e of Employee class (.25 point)
Create an object of Employee class (with name Ahmed and 123 ID)
and assign it to the e reference (.5 point)
Call toString method to print the name and ID. (.25 point)
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