SlideShare a Scribd company logo
1 of 8
Download to read offline
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

Similar to Java inheritance Presentation with Examples

Query Handling System
Query Handling SystemQuery Handling System
Query Handling System
himabindu54
 

Similar to Java inheritance Presentation with Examples (20)

DTEK Talent Management System
DTEK Talent Management SystemDTEK Talent Management System
DTEK Talent Management System
 
Query Handling System
Query Handling SystemQuery Handling System
Query Handling System
 
Quiz Interact
Quiz Interact Quiz Interact
Quiz Interact
 
TeamsNation 2022 - Governance for Microsoft Teams - A to Z.pptx
TeamsNation 2022 - Governance for Microsoft Teams - A to Z.pptxTeamsNation 2022 - Governance for Microsoft Teams - A to Z.pptx
TeamsNation 2022 - Governance for Microsoft Teams - A to Z.pptx
 
Governance in the Modern Workplace: SharePoint, OneDrive, Groups, Teams, Flow...
Governance in the Modern Workplace: SharePoint, OneDrive, Groups, Teams, Flow...Governance in the Modern Workplace: SharePoint, OneDrive, Groups, Teams, Flow...
Governance in the Modern Workplace: SharePoint, OneDrive, Groups, Teams, Flow...
 
Governance in the Modern Workplace: SharePoint, OneDrive, Groups, Teams, Flow...
Governance in the Modern Workplace: SharePoint, OneDrive, Groups, Teams, Flow...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?
ECS19 - Benjamin Niaulin - MOVED TO OFFICE 365, NOW WHAT?ECS19 - Benjamin Niaulin - MOVED TO OFFICE 365, NOW WHAT?
ECS19 - Benjamin Niaulin - MOVED TO OFFICE 365, NOW WHAT?
 
Performance Management - Herman Augnis
Performance Management - Herman Augnis Performance Management - Herman Augnis
Performance Management - Herman Augnis
 
Discovering the New SuccessFactors LMS Admin Features
Discovering the New SuccessFactors LMS Admin FeaturesDiscovering the New SuccessFactors LMS Admin Features
Discovering the New SuccessFactors LMS Admin Features
 
Chapter 3- Performance Management
Chapter 3- Performance ManagementChapter 3- Performance Management
Chapter 3- Performance Management
 
Reward Management
Reward ManagementReward Management
Reward Management
 
Agile certificates, PMI -ACP and Agile practice guide
Agile certificates,  PMI -ACP and Agile practice guideAgile certificates,  PMI -ACP and Agile practice guide
Agile certificates, PMI -ACP and Agile practice guide
 
HR Analytics (2).pptx
HR Analytics (2).pptxHR Analytics (2).pptx
HR Analytics (2).pptx
 
Mini Project.pptx
Mini Project.pptxMini Project.pptx
Mini Project.pptx
 
Oracle Human Capital Management
Oracle Human Capital ManagementOracle Human Capital Management
Oracle Human Capital Management
 
Agile organization design workshop
Agile organization design workshopAgile organization design workshop
Agile organization design workshop
 
From 0 to 100 coaching 100+ teams in an agile transformation by Tolga Kombak...
From 0 to 100  coaching 100+ teams in an agile transformation by Tolga Kombak...From 0 to 100  coaching 100+ teams in an agile transformation by Tolga Kombak...
From 0 to 100 coaching 100+ teams in an agile transformation by Tolga Kombak...
 
Blooms
BloomsBlooms
Blooms
 
Resume
ResumeResume
Resume
 
Job Evaluation Program
Job Evaluation ProgramJob Evaluation Program
Job Evaluation Program
 

Recently uploaded

result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
Tonystark477637
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
dharasingh5698
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Dr.Costas Sachpazis
 

Recently uploaded (20)

result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSIS
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 

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