SlideShare a Scribd company logo
WHAT IS INHERITANCE?
OBJECT-ORIENTED PROGRAMMING
CONCEPTS CONT…
BY AMR ELGHADBAN
Object-Oriented Programming Concepts
WHAT IS INHERITANCE? CONT…
▸ Different kinds of objects often have a certain amount in
common with each other.
▸ Mountain bikes, road bikes, and tandem bikes, for example, all
share the characteristics of bicycles (current speed, current
pedal cadence, current gear).
▸ Yet each also defines additional features that make them
different: tandem bicycles have two seats and two sets of
handlebars, road bikes have drop handlebars, some mountain
bikes have an additional chain ring, giving them a lower gear
ratio.
Object-Oriented Programming Concepts
WHAT IS INHERITANCE? CONT…
▸ Object-oriented
programming allows
classes to inherit
commonly used state
and behavior from other
classes.
▸ A hierarchy of bicycle
classes.
Object-Oriented Programming Concepts
WHAT IS INHERITANCE? CONT…
▸ In this example, Bicycle now becomes the superclass of
MountainBike, RoadBike, and TandemBike. I
▸ n the Java programming language, each class is allowed
to have one direct superclass, and each superclass has the
potential for an unlimited number of subclasses.
Object-Oriented Programming Concepts
WHAT IS INHERITANCE? CONT…
▸ The syntax for creating a subclass is simple. At the
beginning of your class declaration, use the extends
keyword, followed by the name of the class to inherit from:



class MountainBike extends Bicycle { 

//new fields and methods defining 

//montain bike would go here

// write comment here

/* you can also with any comments in this body

that may include multilines */

}
Object-Oriented Programming Concepts
WHAT IS INHERITANCE? CONT…
▸ This gives MountainBike all the same fields and methods
as Bicycle, yet allows its code to focus exclusively on the
features that make it unique.
▸ This makes code for your subclasses easy to read.
However, you must take care to properly document the
state (variables,fields)and behavior (Methods,Functions)
that each superclass (parent class) defines, since that code
will not appear in the source file of each subclass.
THANKS
WISH YOU A WONDERFUL DAY
▸ Skype : amr_elghadban
▸ Email :amr.elghadban@gmail.com
▸ Phone : (+20)1098558500
▸ Fb/amr.elghadban
▸ Linkedin/amr_elghadban

More Related Content

Viewers also liked

9-java language basics part3
9-java language basics part39-java language basics part3
9-java language basics part3
Amr Elghadban (AmrAngry)
 
Object Oriented Paradigm
Object Oriented ParadigmObject Oriented Paradigm
Object Oriented Paradigm
Hüseyin Ergin
 
10- java language basics part4
10- java language basics part410- java language basics part4
10- java language basics part4
Amr Elghadban (AmrAngry)
 
8- java language basics part2
8- java language basics part28- java language basics part2
8- java language basics part2
Amr Elghadban (AmrAngry)
 
Object oriented programming concepts
Object oriented programming conceptsObject oriented programming concepts
Object oriented programming concepts
rahuld115
 
SEMINAR
SEMINARSEMINAR
Spring Framework - Core
Spring Framework - CoreSpring Framework - Core
Spring Framework - Core
Dzmitry Naskou
 
Object-Oriented Programming Concepts
Object-Oriented Programming ConceptsObject-Oriented Programming Concepts
Object-Oriented Programming Concepts
Kwangshin Oh
 
Basic concepts of object oriented programming
Basic concepts of object oriented programmingBasic concepts of object oriented programming
Basic concepts of object oriented programming
Sachin Sharma
 
OOP Principles
OOP PrinciplesOOP Principles
OOP Principles
Dahyun Kim
 
Object Oriented Programming Concepts
Object Oriented Programming ConceptsObject Oriented Programming Concepts
Object Oriented Programming Conceptsthinkphp
 

Viewers also liked (13)

Object Oriented Programming
Object Oriented ProgrammingObject Oriented Programming
Object Oriented Programming
 
9-java language basics part3
9-java language basics part39-java language basics part3
9-java language basics part3
 
Object Oriented Paradigm
Object Oriented ParadigmObject Oriented Paradigm
Object Oriented Paradigm
 
10- java language basics part4
10- java language basics part410- java language basics part4
10- java language basics part4
 
8- java language basics part2
8- java language basics part28- java language basics part2
8- java language basics part2
 
Object oriented programming concepts
Object oriented programming conceptsObject oriented programming concepts
Object oriented programming concepts
 
SEMINAR
SEMINARSEMINAR
SEMINAR
 
Spring Framework - Core
Spring Framework - CoreSpring Framework - Core
Spring Framework - Core
 
Object-Oriented Programming Concepts
Object-Oriented Programming ConceptsObject-Oriented Programming Concepts
Object-Oriented Programming Concepts
 
Lecture 2
Lecture 2Lecture 2
Lecture 2
 
Basic concepts of object oriented programming
Basic concepts of object oriented programmingBasic concepts of object oriented programming
Basic concepts of object oriented programming
 
OOP Principles
OOP PrinciplesOOP Principles
OOP Principles
 
Object Oriented Programming Concepts
Object Oriented Programming ConceptsObject Oriented Programming Concepts
Object Oriented Programming Concepts
 

Similar to 3-oop java-inheritance

Java getstarted
Java getstartedJava getstarted
Java getstarted
Nobin নবীন
 
02 java programming basic
02  java programming basic02  java programming basic
02 java programming basic
Zeeshan-Shaikh
 
Cble assignment powerpoint activity for moodle 1
Cble assignment powerpoint activity for moodle 1Cble assignment powerpoint activity for moodle 1
Cble assignment powerpoint activity for moodle 1
LK394
 
Java OOP Programming language (Part 6) - Abstract Class & Interface
Java OOP Programming language (Part 6) - Abstract Class & InterfaceJava OOP Programming language (Part 6) - Abstract Class & Interface
Java OOP Programming language (Part 6) - Abstract Class & Interface
OUM SAOKOSAL
 
Java OOPS Concept
Java OOPS ConceptJava OOPS Concept
Java OOPS Concept
Richa Gupta
 
OOP-Advanced Programming with c++
OOP-Advanced Programming with c++OOP-Advanced Programming with c++
OOP-Advanced Programming with c++
Mohamed Essam
 
PRG/421 ENTIRE CLASS UOP TUTORIALS
PRG/421 ENTIRE CLASS UOP TUTORIALSPRG/421 ENTIRE CLASS UOP TUTORIALS
PRG/421 ENTIRE CLASS UOP TUTORIALS
Sharon Reynolds
 
L9
L9L9
L9
lksoo
 
The Fast And The Fabulous
The Fast And The FabulousThe Fast And The Fabulous
The Fast And The Fabulous
Nicole Sullivan
 
Inheritance
InheritanceInheritance
Inheritance
Azaz Maverick
 
1.2_IntrotoOOP.pptx
1.2_IntrotoOOP.pptx1.2_IntrotoOOP.pptx
1.2_IntrotoOOP.pptx
ssusercae49e
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
msneha
 
O op lecture 04
O op lecture 04O op lecture 04
O op lecture 04
University of Chitral
 
OOP lecture 04
OOP  lecture 04OOP  lecture 04
OOP lecture 04
University of Chitral
 
jQquerysummit - Large-scale JavaScript Application Architecture
jQquerysummit - Large-scale JavaScript Application Architecture jQquerysummit - Large-scale JavaScript Application Architecture
jQquerysummit - Large-scale JavaScript Application Architecture
Jiby John
 
Intro to iOS Development • Made by Many
Intro to iOS Development • Made by ManyIntro to iOS Development • Made by Many
Intro to iOS Development • Made by Many
kenatmxm
 
Object oriented programming in r
Object oriented programming in r Object oriented programming in r
Object oriented programming in r
Ashwini Mathur
 
Lec18
Lec18Lec18
What I Learned At Drupal Con Dc 2009
What I Learned At Drupal Con Dc 2009What I Learned At Drupal Con Dc 2009
What I Learned At Drupal Con Dc 2009
Neil Giarratana
 

Similar to 3-oop java-inheritance (20)

Java getstarted
Java getstartedJava getstarted
Java getstarted
 
2 oop
2 oop2 oop
2 oop
 
02 java programming basic
02  java programming basic02  java programming basic
02 java programming basic
 
Cble assignment powerpoint activity for moodle 1
Cble assignment powerpoint activity for moodle 1Cble assignment powerpoint activity for moodle 1
Cble assignment powerpoint activity for moodle 1
 
Java OOP Programming language (Part 6) - Abstract Class & Interface
Java OOP Programming language (Part 6) - Abstract Class & InterfaceJava OOP Programming language (Part 6) - Abstract Class & Interface
Java OOP Programming language (Part 6) - Abstract Class & Interface
 
Java OOPS Concept
Java OOPS ConceptJava OOPS Concept
Java OOPS Concept
 
OOP-Advanced Programming with c++
OOP-Advanced Programming with c++OOP-Advanced Programming with c++
OOP-Advanced Programming with c++
 
PRG/421 ENTIRE CLASS UOP TUTORIALS
PRG/421 ENTIRE CLASS UOP TUTORIALSPRG/421 ENTIRE CLASS UOP TUTORIALS
PRG/421 ENTIRE CLASS UOP TUTORIALS
 
L9
L9L9
L9
 
The Fast And The Fabulous
The Fast And The FabulousThe Fast And The Fabulous
The Fast And The Fabulous
 
Inheritance
InheritanceInheritance
Inheritance
 
1.2_IntrotoOOP.pptx
1.2_IntrotoOOP.pptx1.2_IntrotoOOP.pptx
1.2_IntrotoOOP.pptx
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
O op lecture 04
O op lecture 04O op lecture 04
O op lecture 04
 
OOP lecture 04
OOP  lecture 04OOP  lecture 04
OOP lecture 04
 
jQquerysummit - Large-scale JavaScript Application Architecture
jQquerysummit - Large-scale JavaScript Application Architecture jQquerysummit - Large-scale JavaScript Application Architecture
jQquerysummit - Large-scale JavaScript Application Architecture
 
Intro to iOS Development • Made by Many
Intro to iOS Development • Made by ManyIntro to iOS Development • Made by Many
Intro to iOS Development • Made by Many
 
Object oriented programming in r
Object oriented programming in r Object oriented programming in r
Object oriented programming in r
 
Lec18
Lec18Lec18
Lec18
 
What I Learned At Drupal Con Dc 2009
What I Learned At Drupal Con Dc 2009What I Learned At Drupal Con Dc 2009
What I Learned At Drupal Con Dc 2009
 

More from Amr Elghadban (AmrAngry)

Code detox
Code detoxCode detox
08 objective-c session 8
08  objective-c session 808  objective-c session 8
08 objective-c session 8
Amr Elghadban (AmrAngry)
 
07 objective-c session 7
07  objective-c session 707  objective-c session 7
07 objective-c session 7
Amr Elghadban (AmrAngry)
 
05 objective-c session 5
05  objective-c session 505  objective-c session 5
05 objective-c session 5
Amr Elghadban (AmrAngry)
 
04 objective-c session 4
04  objective-c session 404  objective-c session 4
04 objective-c session 4
Amr Elghadban (AmrAngry)
 
03 objective-c session 3
03  objective-c session 303  objective-c session 3
03 objective-c session 3
Amr Elghadban (AmrAngry)
 
02 objective-c session 2
02  objective-c session 202  objective-c session 2
02 objective-c session 2
Amr Elghadban (AmrAngry)
 
01 objective-c session 1
01  objective-c session 101  objective-c session 1
01 objective-c session 1
Amr Elghadban (AmrAngry)
 
00 intro ios
00 intro ios00 intro ios

More from Amr Elghadban (AmrAngry) (9)

Code detox
Code detoxCode detox
Code detox
 
08 objective-c session 8
08  objective-c session 808  objective-c session 8
08 objective-c session 8
 
07 objective-c session 7
07  objective-c session 707  objective-c session 7
07 objective-c session 7
 
05 objective-c session 5
05  objective-c session 505  objective-c session 5
05 objective-c session 5
 
04 objective-c session 4
04  objective-c session 404  objective-c session 4
04 objective-c session 4
 
03 objective-c session 3
03  objective-c session 303  objective-c session 3
03 objective-c session 3
 
02 objective-c session 2
02  objective-c session 202  objective-c session 2
02 objective-c session 2
 
01 objective-c session 1
01  objective-c session 101  objective-c session 1
01 objective-c session 1
 
00 intro ios
00 intro ios00 intro ios
00 intro ios
 

Recently uploaded

A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
名前 です男
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
KAMESHS29
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex ProofszkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
Alex Pruden
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
Kumud Singh
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
nkrafacyberclub
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems S.M.S.A.
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
Neo4j
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
Matthew Sinclair
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
RinaMondal9
 

Recently uploaded (20)

A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex ProofszkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
 

3-oop java-inheritance

  • 1. WHAT IS INHERITANCE? OBJECT-ORIENTED PROGRAMMING CONCEPTS CONT… BY AMR ELGHADBAN
  • 2. Object-Oriented Programming Concepts WHAT IS INHERITANCE? CONT… ▸ Different kinds of objects often have a certain amount in common with each other. ▸ Mountain bikes, road bikes, and tandem bikes, for example, all share the characteristics of bicycles (current speed, current pedal cadence, current gear). ▸ Yet each also defines additional features that make them different: tandem bicycles have two seats and two sets of handlebars, road bikes have drop handlebars, some mountain bikes have an additional chain ring, giving them a lower gear ratio.
  • 3. Object-Oriented Programming Concepts WHAT IS INHERITANCE? CONT… ▸ Object-oriented programming allows classes to inherit commonly used state and behavior from other classes. ▸ A hierarchy of bicycle classes.
  • 4. Object-Oriented Programming Concepts WHAT IS INHERITANCE? CONT… ▸ In this example, Bicycle now becomes the superclass of MountainBike, RoadBike, and TandemBike. I ▸ n the Java programming language, each class is allowed to have one direct superclass, and each superclass has the potential for an unlimited number of subclasses.
  • 5. Object-Oriented Programming Concepts WHAT IS INHERITANCE? CONT… ▸ The syntax for creating a subclass is simple. At the beginning of your class declaration, use the extends keyword, followed by the name of the class to inherit from:
 
 class MountainBike extends Bicycle { 
 //new fields and methods defining 
 //montain bike would go here
 // write comment here
 /* you can also with any comments in this body
 that may include multilines */
 }
  • 6. Object-Oriented Programming Concepts WHAT IS INHERITANCE? CONT… ▸ This gives MountainBike all the same fields and methods as Bicycle, yet allows its code to focus exclusively on the features that make it unique. ▸ This makes code for your subclasses easy to read. However, you must take care to properly document the state (variables,fields)and behavior (Methods,Functions) that each superclass (parent class) defines, since that code will not appear in the source file of each subclass.
  • 7. THANKS WISH YOU A WONDERFUL DAY ▸ Skype : amr_elghadban ▸ Email :amr.elghadban@gmail.com ▸ Phone : (+20)1098558500 ▸ Fb/amr.elghadban ▸ Linkedin/amr_elghadban