Answered step by step
Verified Expert Solution
Link Copied!

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

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

Database Concepts

Authors: David M. Kroenke

1st Edition

0130086509, 978-0130086501

More Books

Students also viewed these Databases questions