SlideShare a Scribd company logo
2
Most read
Create a class named Person. The person class contains first name, middle name, and last
name.Then create a sub-class named Employee that inherits the properties and attributes of the
Person super class. The Employee class returns the first name, middle name, last name and
employee ID of two employees.
Solution
Hi, Please find my implementation.
Please let me know in case of any issue.
public class Person {
// protected instant members
protected String firstName;
protected String middleName;
protected String lastName;
// constructor
public Person(){
firstName = "";
middleName = "";
lastName = "";
}
public Person(String fname, String mname, String lname){
firstName = fname;
middleName = mname;
lastName = lname;
}
}
class Employee extends Person{
// instance members
private String employeeID;
// constructor
public Employee(String id) {
employeeID = id;
}
public Employee(String fname, String mname, String lname, String id){
super(fname, mname, lname);
employeeID = id;
}
// setters and getters
public String getEmployeeID() {
return employeeID;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getMiddleName() {
return middleName;
}
public void setMiddleName(String middleName) {
this.middleName = middleName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
@Override
public String toString() {
return "First Name: "+firstName+" "+
"Middle Name: "+middleName+" "+
"Last Name: "+lastName+" "+
"Id: "+employeeID;
}
}

More Related Content

PPT
Java for the Impatient, Java Constructors, Scope, Wrappers, Inheritance, and ...
PDF
Hello. Im currently working on the last section to my assignment a.pdf
PPT
Php object orientation and classes
PDF
Demystifying oop
PPT
Java: Inheritance
PDF
Add a private variable SSN to the person class- Add a private variable.pdf
PDF
Demystifying Object-Oriented Programming - Lone Star PHP
PDF
Demystifying Object-Oriented Programming - PHP[tek] 2017
Java for the Impatient, Java Constructors, Scope, Wrappers, Inheritance, and ...
Hello. Im currently working on the last section to my assignment a.pdf
Php object orientation and classes
Demystifying oop
Java: Inheritance
Add a private variable SSN to the person class- Add a private variable.pdf
Demystifying Object-Oriented Programming - Lone Star PHP
Demystifying Object-Oriented Programming - PHP[tek] 2017

Similar to Create a class named Person. The person class contains first name, .pdf (20)

DOCX
Chapter 2 -ava Fundamentals Code Listing 2-32 (NameaDialog- Java) Unit.docx
PPT
شرح مقرر البرمجة 2 لغة جافا - الوحدة الرابعة
PPTX
Simple class and object examples in java
PDF
Demystifying Object-Oriented Programming - ZendCon 2016
PPTX
Object oriented concepts
PDF
Lect 1-java object-classes
PPTX
Computer programming 2 -lesson 4
DOCX
OOP Lab Report.docx
PDF
Demystifying Object-Oriented Programming #phpbnl18
DOCX
Assignment 7
PDF
Demystifying Object-Oriented Programming - PHP UK Conference 2017
PPT
Python session 7 by Shan
PDF
Self, Class and Module
PDF
Demystifying Object-Oriented Programming - Midwest PHP
PDF
HELP IN JAVACreate a main method and use these input files to tes.pdf
PDF
define a class name Employee whose objects are records for employee..pdf
DOCX
2. Create a Java class called EmployeeMain within the same project Pr.docx
PPT
14. Defining Classes
PPTX
Lecture 17 - PHP-Object-Orientation.pptx
DOCX
CSE 110 - Lab 6 What this Lab Is About  Working wi.docx
Chapter 2 -ava Fundamentals Code Listing 2-32 (NameaDialog- Java) Unit.docx
شرح مقرر البرمجة 2 لغة جافا - الوحدة الرابعة
Simple class and object examples in java
Demystifying Object-Oriented Programming - ZendCon 2016
Object oriented concepts
Lect 1-java object-classes
Computer programming 2 -lesson 4
OOP Lab Report.docx
Demystifying Object-Oriented Programming #phpbnl18
Assignment 7
Demystifying Object-Oriented Programming - PHP UK Conference 2017
Python session 7 by Shan
Self, Class and Module
Demystifying Object-Oriented Programming - Midwest PHP
HELP IN JAVACreate a main method and use these input files to tes.pdf
define a class name Employee whose objects are records for employee..pdf
2. Create a Java class called EmployeeMain within the same project Pr.docx
14. Defining Classes
Lecture 17 - PHP-Object-Orientation.pptx
CSE 110 - Lab 6 What this Lab Is About  Working wi.docx
Ad

More from arrowcomputers8700 (20)

PDF
How are control charts madeSolutionThe control chart is a gra.pdf
PDF
GENETICS Millie bought three packages of zinnia seeds for red, orang.pdf
PDF
Figure 5.2 shows a common biological phospholipid called phosphatidy.pdf
PDF
Discuss the relationship between some of the common file classes in .pdf
PDF
describe the cell categories of nervous tissue and describe the orga.pdf
PDF
Describe what is meant by the Internet of Things. What industrie.pdf
PDF
C++ Programming Language N-number queue rotations.Write methods v.pdf
PDF
Assume a disease is dominant, indicated by shading. Based on the pedi.pdf
PDF
Chorismate 3-glycero phosphate Relying on the above pathway for b.pdf
PDF
A form of favoritism where you give preferential treatment to your f.pdf
PDF
2.Describe a technique that would allow a developmental biologist to.pdf
PDF
4. Smircich and Morgan (1982), in an earlier reading, identified “le.pdf
PDF
You are required to write an interactive C program that prompts the .pdf
PDF
Which plant cell organelle contains its own DNA and ribosome A) Golg.pdf
PDF
A living plant leaf is an open system that exchanges energy (sunligh.pdf
PDF
Which of the following are typically used as input devices A. Print.pdf
PDF
What is dynamic semantics Can you please explain the many kinds of .pdf
PDF
What happened to Mexicans in the west after the US annexed their lan.pdf
PDF
What are pivot tablesWhat is the table format and how can it save.pdf
PDF
Topology - Imbeddings of Manifolds Prove that every manifold is regu.pdf
How are control charts madeSolutionThe control chart is a gra.pdf
GENETICS Millie bought three packages of zinnia seeds for red, orang.pdf
Figure 5.2 shows a common biological phospholipid called phosphatidy.pdf
Discuss the relationship between some of the common file classes in .pdf
describe the cell categories of nervous tissue and describe the orga.pdf
Describe what is meant by the Internet of Things. What industrie.pdf
C++ Programming Language N-number queue rotations.Write methods v.pdf
Assume a disease is dominant, indicated by shading. Based on the pedi.pdf
Chorismate 3-glycero phosphate Relying on the above pathway for b.pdf
A form of favoritism where you give preferential treatment to your f.pdf
2.Describe a technique that would allow a developmental biologist to.pdf
4. Smircich and Morgan (1982), in an earlier reading, identified “le.pdf
You are required to write an interactive C program that prompts the .pdf
Which plant cell organelle contains its own DNA and ribosome A) Golg.pdf
A living plant leaf is an open system that exchanges energy (sunligh.pdf
Which of the following are typically used as input devices A. Print.pdf
What is dynamic semantics Can you please explain the many kinds of .pdf
What happened to Mexicans in the west after the US annexed their lan.pdf
What are pivot tablesWhat is the table format and how can it save.pdf
Topology - Imbeddings of Manifolds Prove that every manifold is regu.pdf
Ad

Recently uploaded (20)

DOC
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PPTX
Lesson notes of climatology university.
PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
PPTX
Orientation - ARALprogram of Deped to the Parents.pptx
PDF
Paper A Mock Exam 9_ Attempt review.pdf.
PDF
What if we spent less time fighting change, and more time building what’s rig...
PPTX
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
PPTX
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
Updated Idioms and Phrasal Verbs in English subject
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PPTX
master seminar digital applications in india
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
ChatGPT for Dummies - Pam Baker Ccesa007.pdf
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Lesson notes of climatology university.
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
Orientation - ARALprogram of Deped to the Parents.pptx
Paper A Mock Exam 9_ Attempt review.pdf.
What if we spent less time fighting change, and more time building what’s rig...
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
STATICS OF THE RIGID BODIES Hibbelers.pdf
Microbial disease of the cardiovascular and lymphatic systems
Updated Idioms and Phrasal Verbs in English subject
Anesthesia in Laparoscopic Surgery in India
Supply Chain Operations Speaking Notes -ICLT Program
master seminar digital applications in india
2.FourierTransform-ShortQuestionswithAnswers.pdf
ChatGPT for Dummies - Pam Baker Ccesa007.pdf

Create a class named Person. The person class contains first name, .pdf

  • 1. Create a class named Person. The person class contains first name, middle name, and last name.Then create a sub-class named Employee that inherits the properties and attributes of the Person super class. The Employee class returns the first name, middle name, last name and employee ID of two employees. Solution Hi, Please find my implementation. Please let me know in case of any issue. public class Person { // protected instant members protected String firstName; protected String middleName; protected String lastName; // constructor public Person(){ firstName = ""; middleName = ""; lastName = ""; } public Person(String fname, String mname, String lname){ firstName = fname; middleName = mname; lastName = lname; } } class Employee extends Person{ // instance members private String employeeID; // constructor
  • 2. public Employee(String id) { employeeID = id; } public Employee(String fname, String mname, String lname, String id){ super(fname, mname, lname); employeeID = id; } // setters and getters public String getEmployeeID() { return employeeID; } public String getFirstName() { return firstName; } public void setFirstName(String firstName) { this.firstName = firstName; } public String getMiddleName() { return middleName; } public void setMiddleName(String middleName) { this.middleName = middleName; } public String getLastName() { return lastName; } public void setLastName(String lastName) { this.lastName = lastName; } @Override public String toString() {
  • 3. return "First Name: "+firstName+" "+ "Middle Name: "+middleName+" "+ "Last Name: "+lastName+" "+ "Id: "+employeeID; } }