SlideShare uma empresa Scribd logo
1 de 7
Baixar para ler offline
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

Mais conteúdo relacionado

Destaque

Object Oriented Programming Concepts
Object Oriented Programming ConceptsObject Oriented Programming Concepts
Object Oriented Programming Concepts
thinkphp
 

Destaque (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
 

Semelhante a 3-oop java-inheritance

OOP-Advanced Programming with c++
OOP-Advanced Programming with c++OOP-Advanced Programming with c++
OOP-Advanced Programming with c++
Mohamed Essam
 

Semelhante a 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
 

Mais de Amr Elghadban (AmrAngry)

Mais de 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
 

Último

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Último (20)

Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 

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