SlideShare a Scribd company logo
Object Oriented Programming
Lab
CS123
Noushin Saba
Asfand Yar
Lab # 6
Inheritance
Inheritance
• One class acquires the properties and behavior of another class
• Represents a parent-child relationship between two classes
• Subclass
• A subclass, also known as a child class or derived class, is the class that inherits the properties
and behaviors of another class
• Superclass
• A superclass, also known as a parent class or base class, is a class whose properties and
behaviors are inherited by the subclass
• Implemented using the extends keyword
Account Class
• Superclass
• Attributes
• accountNumber, balance, and withdrawal limits
• Constructor
• No argument constructor
• Parameterized constructor
• Methods
• Set and get methods
• Depositing amount
• Withdrawing amount
• Calculating interest
• Displaying account information
CheckingAccount Class
• Subclass inherited from Account
• Attributes
• Overdraft Limit
• Constructor
• No argument constructor
• Parameterized constructor
• Methods
• Get and set methods
• Overrides withdraw method to handle overdrafts
• Overrides display information
Tasks
Task 1: Saving Account inherited from Account class
• Create a SavingAccount subclass with the following:
• Attributes
• Interest rate
• Constructor
• No argument constructor
• Parameterized constructor
• Methods
• Get and set methods
• Override calculate interest method
• Override display information
• Write main to check the functionality of SavingAccount
Tasks
• Task 2: Employee, Manager, Team Lead
Employee: This is the base class representing generic employees in the company. It
might contain attributes like name, employee ID, and methods for calculating salary
or displaying employee information.
Manager: The Manager class inherits from Employee and adds specific attributes
and behaviors relevant to managers, such as managing a team, approving leave
requests, or conducting performance reviews.
TeamLead: The TeamLead class further specializes in Managers. It inherits all the
attributes and behaviors of a Manager but may add additional features specific to
team leaders, like assigning tasks, mentoring team members, or coordinating team
meetings.
Tasks
• Employee class
• Attributes
• Name (first, last)
• Employee ID
• Employment status – Active
• Hire date
• Email address
• Phone number
• Department
• Position
• Salary
• Methods
• Get and Set Method
• Promote (change position)
• Terminate (change employment
status)
• Manager class
• Attributes
• Direct Reports (List of
Employees)
• Project (List)
• Methods
• Add direct reports
• Assign Projects
• Evaluate Performance
• TeamLead class
• Attributes
• Team name
• Team Tasks (List)
• Methods
• Hold team meeting
• Add and display team
tasks

More Related Content

PPT
PDF
Hcm file-wp
PPT
workday hcm training | workday hcm online training | workday hcm course
PPTX
Benefits of Automating Performance Reviews with Software
PPTX
sanjaygowda55k Performance appraisal HRM
PDF
SAP Success Factor learning |Success Factor Online Training Course pdf
PDF
EmpXtrack's Performance Management System - Datasheet
PPTX
CM - JOB Eval updated CM - JOB Eval updated.pptx
Hcm file-wp
workday hcm training | workday hcm online training | workday hcm course
Benefits of Automating Performance Reviews with Software
sanjaygowda55k Performance appraisal HRM
SAP Success Factor learning |Success Factor Online Training Course pdf
EmpXtrack's Performance Management System - Datasheet
CM - JOB Eval updated CM - JOB Eval updated.pptx

Similar to Java inheritance Presentation with Examples (20)

PPTX
JOB Eval updated CM - JOB Eval updated.pptx
PPTX
cnzvkjdnvkdfnbxcbxcvxbvcvbfgmxnbmfnbxfnbxmcvbc
PDF
HR - Job Analysis
PDF
DTEK Talent Management System
PPTX
Query Handling System
PPTX
PPTX
074.5.2 Performance appraisal 074.4.31.pptx
PPTX
TeamsNation 2022 - Governance for Microsoft Teams - A to Z.pptx
PPT
Performance appraisals powerpoint presentation
PPTX
Governance in the Modern Workplace: SharePoint, OneDrive, Groups, Teams, Flow...
PPTX
Governance in the Modern Workplace: SharePoint, OneDrive, Groups, Teams, Flow...
PDF
ECS19 - Benjamin Niaulin - MOVED TO OFFICE 365, NOW WHAT?
PDF
Performance Management - Herman Augnis
PPTX
Discovering the New SuccessFactors LMS Admin Features
PPTX
Chapter 3- Performance Management
PPTX
Reward Management
PPTX
PERFORMANCE MANAGEMENT SYSTEM presentation.pptx
PDF
Agile certificates, PMI -ACP and Agile practice guide
PPTX
HR Analytics (2).pptx
PPTX
Mini Project.pptx
JOB Eval updated CM - JOB Eval updated.pptx
cnzvkjdnvkdfnbxcbxcvxbvcvbfgmxnbmfnbxfnbxmcvbc
HR - Job Analysis
DTEK Talent Management System
Query Handling System
074.5.2 Performance appraisal 074.4.31.pptx
TeamsNation 2022 - Governance for Microsoft Teams - A to Z.pptx
Performance appraisals powerpoint presentation
Governance in the Modern Workplace: SharePoint, OneDrive, Groups, Teams, Flow...
Governance in the Modern Workplace: SharePoint, OneDrive, Groups, Teams, Flow...
ECS19 - Benjamin Niaulin - MOVED TO OFFICE 365, NOW WHAT?
Performance Management - Herman Augnis
Discovering the New SuccessFactors LMS Admin Features
Chapter 3- Performance Management
Reward Management
PERFORMANCE MANAGEMENT SYSTEM presentation.pptx
Agile certificates, PMI -ACP and Agile practice guide
HR Analytics (2).pptx
Mini Project.pptx
Ad

Recently uploaded (20)

PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PDF
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
PDF
Well-logging-methods_new................
PDF
Model Code of Practice - Construction Work - 21102022 .pdf
PPT
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
PDF
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PPTX
CH1 Production IntroductoryConcepts.pptx
PDF
Digital Logic Computer Design lecture notes
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PDF
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
PPTX
OOP with Java - Java Introduction (Basics)
DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PDF
R24 SURVEYING LAB MANUAL for civil enggi
PPTX
bas. eng. economics group 4 presentation 1.pptx
PPTX
Sustainable Sites - Green Building Construction
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
Well-logging-methods_new................
Model Code of Practice - Construction Work - 21102022 .pdf
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
CH1 Production IntroductoryConcepts.pptx
Digital Logic Computer Design lecture notes
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
OOP with Java - Java Introduction (Basics)
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
R24 SURVEYING LAB MANUAL for civil enggi
bas. eng. economics group 4 presentation 1.pptx
Sustainable Sites - Green Building Construction
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
CYBER-CRIMES AND SECURITY A guide to understanding
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
Ad

Java inheritance Presentation with Examples

  • 3. Inheritance • One class acquires the properties and behavior of another class • Represents a parent-child relationship between two classes • Subclass • A subclass, also known as a child class or derived class, is the class that inherits the properties and behaviors of another class • Superclass • A superclass, also known as a parent class or base class, is a class whose properties and behaviors are inherited by the subclass • Implemented using the extends keyword
  • 4. Account Class • Superclass • Attributes • accountNumber, balance, and withdrawal limits • Constructor • No argument constructor • Parameterized constructor • Methods • Set and get methods • Depositing amount • Withdrawing amount • Calculating interest • Displaying account information
  • 5. CheckingAccount Class • Subclass inherited from Account • Attributes • Overdraft Limit • Constructor • No argument constructor • Parameterized constructor • Methods • Get and set methods • Overrides withdraw method to handle overdrafts • Overrides display information
  • 6. Tasks Task 1: Saving Account inherited from Account class • Create a SavingAccount subclass with the following: • Attributes • Interest rate • Constructor • No argument constructor • Parameterized constructor • Methods • Get and set methods • Override calculate interest method • Override display information • Write main to check the functionality of SavingAccount
  • 7. Tasks • Task 2: Employee, Manager, Team Lead Employee: This is the base class representing generic employees in the company. It might contain attributes like name, employee ID, and methods for calculating salary or displaying employee information. Manager: The Manager class inherits from Employee and adds specific attributes and behaviors relevant to managers, such as managing a team, approving leave requests, or conducting performance reviews. TeamLead: The TeamLead class further specializes in Managers. It inherits all the attributes and behaviors of a Manager but may add additional features specific to team leaders, like assigning tasks, mentoring team members, or coordinating team meetings.
  • 8. Tasks • Employee class • Attributes • Name (first, last) • Employee ID • Employment status – Active • Hire date • Email address • Phone number • Department • Position • Salary • Methods • Get and Set Method • Promote (change position) • Terminate (change employment status) • Manager class • Attributes • Direct Reports (List of Employees) • Project (List) • Methods • Add direct reports • Assign Projects • Evaluate Performance • TeamLead class • Attributes • Team name • Team Tasks (List) • Methods • Hold team meeting • Add and display team tasks