Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!