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 person , that has the following members: a private String attribute
Write a JAVA code to implement the following:
1. Create a super class named person, that has the following members:
- a private String attribute name and integer id
- constructor to initialize the attribute name and id.
- set method to change the values of name.
- get method to return the values of name.
- override method toString to print the value of name and id. (
2. Create a sub class named student that,
- inherits from superclass person
- has a private attribute address
- constructor to initialize the attributes name
(via superclass constructor) , ID and address
3. Write a Test class that has the main method:
- Declare a reference e of student class
- Create an object of student class (with name Mohamed and 321 ID)
and assign it to the e reference
Call toString method to print the name and ID.
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