SlideShare ist ein Scribd-Unternehmen logo
1 von 66
OBJECT ORIENTED PROGRAMMING
INDEX  UNIT 3 PPT SLIDES ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Hierarchical Abstraction ,[object Object],[object Object],[object Object],[object Object]
Class Hierarchy ,[object Object],Animal Reptile Bird Mammal Snake Lizard Bat Horse Parrot ,[object Object]
Class Hierarchy ,[object Object],[object Object],[object Object],[object Object]
Base Class  Object ,[object Object],[object Object],[object Object]
Base Class  Object (cont) ,[object Object],[object Object],[object Object],[object Object],[object Object]
Base class ,[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
extends ,[object Object],[object Object],class One { int a=5; } class Two extends One { int b=10; }
[object Object],[object Object],[object Object],[object Object]
Subclass, Subtype and Substitutability ,[object Object],[object Object],[object Object]
Subclass, Subtype, and Substitutability ,[object Object],[object Object],[object Object]
Subclass, Subtype, and Substitutability ,[object Object],[object Object],[object Object],[object Object]
Subclass, Subtype, and Substitutability ,[object Object],[object Object],[object Object]
Subclass ,[object Object],[object Object],[object Object],[object Object],[object Object]
Subtype  ,[object Object],+ fly() : void Animal weight : int + getWeight() : int Bird
Substitutability (Deriving Subclasses) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Defining Methods in the Child Class: Overriding by Replacement ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Forms of Inheritance ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Forms of Inheritance (-  Inheritance for Specialization  - ) Most commonly used inheritance and sub classification is for specialization. Always creates a subtype, and the principles of substitutability is explicitly upheld. It is the most ideal form of inheritance.  An example of subclassification for specialization is; public class PinBallGame extends Frame { // body of class }
Specialization ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Forms of Inheritance (-  Inheritance for Specification  - ) This is another most common use of inheritance. Two different mechanisms are provided by Java,  interface  and  abstract , to make use of  subclassification for specification . Subtype is formed and substitutability is explicitly upheld. Mostly, not used for refinement of its parent class, but instead is used for definitions of the properties provided by its parent.  class FireButtonListener implements ActionListener { // body of class } class B extends A { // class A is defined as abstract specification class }
Specification ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Forms of Inheritance (-  Inheritance for Construction  - ) Child class inherits most of its functionality from parent, but may change the name or parameters of methods inherited from parent class to form its interface. This type of inheritance is also widely used for code reuse purposes. It simplifies the construction of newly formed abstraction but is not a form of subtype, and often violates substitutability. Example is  Stack  class defined in Java libraries .
Construction ,[object Object],[object Object],[object Object],[object Object]
Forms of Inheritance (-  Inheritance for Extension  - ) Subclassification for extension occurs when a child class only adds new behavior to the parent class and does not modify or alter any of the inherited attributes. Such subclasses are always subtypes, and substitutability can be used. Example of this type of inheritance is done in the definition of the class  Properties  which is an extension of the class  HashTable .
Generalization or Extension ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Forms of Inheritance (-  Inheritance for Limitation  - ) Subclassification for limitation occurs when the behavior of the subclass is smaller or more restrictive that the behavior of its parent class.  Like subclassification for extension, this form of inheritance occurs most frequently when a programmer is building on a base of existing classes. Is not a subtype, and substitutability is not proper.
Limitation ,[object Object],[object Object],[object Object]
Forms of Inheritance (-  Inheritance for Combination  - ) This types of inheritance is known as  multiple inheritance  in Object Oriented Programming.  Although the Java does not permit a subclass to be formed be inheritance from more than one parent class, several approximations to the concept are possible. Example of this type is  Hole  class defined as; class  Hole extends Ball implements PinBallTarget{ // body of class }
Combimnation ,[object Object],[object Object],[object Object]
Summary of Forms of Inheritance ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
The Benefits of Inheritance ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
The Costs of Inheritance ,[object Object],[object Object],[object Object],[object Object]
Types of inheritance   ,[object Object],[object Object],[object Object],SUB SUPER SUB 1 SUB 2 extends extends SUPER
2 .   Multi Level Inheritance 3.  Multiple Inheritance SUPER SUB SUB SUB SUPER 1 SUPER 2 extends extends implements SUB SUPER 1 SUPER 2 implements SUB extends
Member access rules ,[object Object],[object Object],[object Object],[object Object]
Modifiers and Inheritance  (cont.) ,[object Object],[object Object],[object Object],[object Object],[object Object]
The  protected  Modifier ,[object Object],[object Object],[object Object],Dictionary + getDefinitions() : int + setDefinitions():  void + computeRatios() : double  Book protected int pages + getPages() : int + setPages(): void
Example: Super-Class ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Example: Sub-Class ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Example: Testing Class ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Multi-Level Class Hierarchy ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Multi-Level Class Hierarchy  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Multi-Level Class Hierarchy ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Multi-Level Class Hierarchy ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Multi-Level Class Hierarchy ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
“ super ” uses ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Super and Hiding ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Example: Super and Hiding  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Example: Super and Hiding  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Using final with inheritance ,[object Object],[object Object],[object Object],[object Object]
Preventing Overriding with final ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Preventing Inheritance with final ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Polymorphism ,[object Object],[object Object],[object Object],[object Object],[object Object]
Polymorphism ,[object Object],[object Object],[object Object],[object Object],[object Object]
Method Overriding ,[object Object],[object Object],[object Object],[object Object]
Example: Hiding with Overriding 1 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Example: Hiding with Overriding 2 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Example: Hiding with Overriding 3 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Overloading vs. Overriding ,[object Object],[object Object],[object Object],[object Object]
Abstract Classes ,[object Object],[object Object],[object Object],Vehicle Car Boat Plane
Abstract Class: Example ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Abstract Classes ,[object Object],[object Object],[object Object],[object Object],[object Object]
Abstract Method ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]

Weitere ähnliche Inhalte

Was ist angesagt?

Java Presentation
Java PresentationJava Presentation
Java Presentation
pm2214
 
Classes, objects in JAVA
Classes, objects in JAVAClasses, objects in JAVA
Classes, objects in JAVA
Abhilash Nair
 

Was ist angesagt? (20)

Java Exception handling
Java Exception handlingJava Exception handling
Java Exception handling
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
 
Interfaces in java
Interfaces in javaInterfaces in java
Interfaces in java
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
 
Java packages
Java packagesJava packages
Java packages
 
OCA Java SE 8 Exam Chapter 4 Methods Encapsulation
OCA Java SE 8 Exam Chapter 4 Methods EncapsulationOCA Java SE 8 Exam Chapter 4 Methods Encapsulation
OCA Java SE 8 Exam Chapter 4 Methods Encapsulation
 
Java Presentation
Java PresentationJava Presentation
Java Presentation
 
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B KuteChapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
 
Inheritance
InheritanceInheritance
Inheritance
 
What is Interface in Java | How to implement Multiple Inheritance Using Inter...
What is Interface in Java | How to implement Multiple Inheritance Using Inter...What is Interface in Java | How to implement Multiple Inheritance Using Inter...
What is Interface in Java | How to implement Multiple Inheritance Using Inter...
 
Constructor in java
Constructor in javaConstructor in java
Constructor in java
 
Unit 7 Java
Unit 7 JavaUnit 7 Java
Unit 7 Java
 
Java And Multithreading
Java And MultithreadingJava And Multithreading
Java And Multithreading
 
Inheritance in OOPS
Inheritance in OOPSInheritance in OOPS
Inheritance in OOPS
 
Classes, objects in JAVA
Classes, objects in JAVAClasses, objects in JAVA
Classes, objects in JAVA
 
Unit 6 Java
Unit 6 JavaUnit 6 Java
Unit 6 Java
 
Java multi threading
Java multi threadingJava multi threading
Java multi threading
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
 
Inheritance In Java
Inheritance In JavaInheritance In Java
Inheritance In Java
 
This keyword in java
This keyword in javaThis keyword in java
This keyword in java
 

Ähnlich wie Unit 3 Java

Ap Power Point Chpt7
Ap Power Point Chpt7Ap Power Point Chpt7
Ap Power Point Chpt7
dplunkett
 
9781439035665 ppt ch10
9781439035665 ppt ch109781439035665 ppt ch10
9781439035665 ppt ch10
Terry Yoast
 
oops-123991513147-phpapp02.pdf
oops-123991513147-phpapp02.pdfoops-123991513147-phpapp02.pdf
oops-123991513147-phpapp02.pdf
ArpitaJana28
 

Ähnlich wie Unit 3 Java (20)

Java programming -Object-Oriented Thinking- Inheritance
Java programming -Object-Oriented Thinking- InheritanceJava programming -Object-Oriented Thinking- Inheritance
Java programming -Object-Oriented Thinking- Inheritance
 
Java inheritance
Java inheritanceJava inheritance
Java inheritance
 
Inheritance and its necessity in java.ppt
Inheritance and its necessity in java.pptInheritance and its necessity in java.ppt
Inheritance and its necessity in java.ppt
 
Ap Power Point Chpt7
Ap Power Point Chpt7Ap Power Point Chpt7
Ap Power Point Chpt7
 
OCA Java SE 8 Exam Chapter 5 Class Design
OCA Java SE 8 Exam Chapter 5 Class DesignOCA Java SE 8 Exam Chapter 5 Class Design
OCA Java SE 8 Exam Chapter 5 Class Design
 
9781439035665 ppt ch10
9781439035665 ppt ch109781439035665 ppt ch10
9781439035665 ppt ch10
 
Inheritance and Substitution
Inheritance and SubstitutionInheritance and Substitution
Inheritance and Substitution
 
Java basics
Java basicsJava basics
Java basics
 
Oops
OopsOops
Oops
 
Lecture 12
Lecture 12Lecture 12
Lecture 12
 
Android Training (Java Review)
Android Training (Java Review)Android Training (Java Review)
Android Training (Java Review)
 
C# interview
C# interviewC# interview
C# interview
 
Java chapter 5
Java chapter 5Java chapter 5
Java chapter 5
 
Chap11
Chap11Chap11
Chap11
 
Question and answer Programming
Question and answer ProgrammingQuestion and answer Programming
Question and answer Programming
 
oops-123991513147-phpapp02.pdf
oops-123991513147-phpapp02.pdfoops-123991513147-phpapp02.pdf
oops-123991513147-phpapp02.pdf
 
Java - Inheritance Concepts
Java - Inheritance ConceptsJava - Inheritance Concepts
Java - Inheritance Concepts
 
Micro Anti-patterns in Java Code
Micro Anti-patterns in Java CodeMicro Anti-patterns in Java Code
Micro Anti-patterns in Java Code
 
Classes2
Classes2Classes2
Classes2
 
Ruby object model
Ruby object modelRuby object model
Ruby object model
 

Mehr von arnold 7490 (20)

Les14
Les14Les14
Les14
 
Les13
Les13Les13
Les13
 
Les11
Les11Les11
Les11
 
Les10
Les10Les10
Les10
 
Les09
Les09Les09
Les09
 
Les07
Les07Les07
Les07
 
Les06
Les06Les06
Les06
 
Les05
Les05Les05
Les05
 
Les04
Les04Les04
Les04
 
Les03
Les03Les03
Les03
 
Les02
Les02Les02
Les02
 
Les01
Les01Les01
Les01
 
Les12
Les12Les12
Les12
 
Unit 8 Java
Unit 8 JavaUnit 8 Java
Unit 8 Java
 
Unit 5 Java
Unit 5 JavaUnit 5 Java
Unit 5 Java
 
Unit6 C
Unit6 C Unit6 C
Unit6 C
 
Unit5 C
Unit5 C Unit5 C
Unit5 C
 
Unit4 C
Unit4 C Unit4 C
Unit4 C
 
Unit3 C
Unit3 C Unit3 C
Unit3 C
 
Unit2 C
Unit2 C Unit2 C
Unit2 C
 

Kürzlich hochgeladen

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Kürzlich hochgeladen (20)

Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
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)
 
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
 

Unit 3 Java

  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21. Forms of Inheritance (- Inheritance for Specialization - ) Most commonly used inheritance and sub classification is for specialization. Always creates a subtype, and the principles of substitutability is explicitly upheld. It is the most ideal form of inheritance. An example of subclassification for specialization is; public class PinBallGame extends Frame { // body of class }
  • 22.
  • 23. Forms of Inheritance (- Inheritance for Specification - ) This is another most common use of inheritance. Two different mechanisms are provided by Java, interface and abstract , to make use of subclassification for specification . Subtype is formed and substitutability is explicitly upheld. Mostly, not used for refinement of its parent class, but instead is used for definitions of the properties provided by its parent. class FireButtonListener implements ActionListener { // body of class } class B extends A { // class A is defined as abstract specification class }
  • 24.
  • 25. Forms of Inheritance (- Inheritance for Construction - ) Child class inherits most of its functionality from parent, but may change the name or parameters of methods inherited from parent class to form its interface. This type of inheritance is also widely used for code reuse purposes. It simplifies the construction of newly formed abstraction but is not a form of subtype, and often violates substitutability. Example is Stack class defined in Java libraries .
  • 26.
  • 27. Forms of Inheritance (- Inheritance for Extension - ) Subclassification for extension occurs when a child class only adds new behavior to the parent class and does not modify or alter any of the inherited attributes. Such subclasses are always subtypes, and substitutability can be used. Example of this type of inheritance is done in the definition of the class Properties which is an extension of the class HashTable .
  • 28.
  • 29. Forms of Inheritance (- Inheritance for Limitation - ) Subclassification for limitation occurs when the behavior of the subclass is smaller or more restrictive that the behavior of its parent class. Like subclassification for extension, this form of inheritance occurs most frequently when a programmer is building on a base of existing classes. Is not a subtype, and substitutability is not proper.
  • 30.
  • 31. Forms of Inheritance (- Inheritance for Combination - ) This types of inheritance is known as multiple inheritance in Object Oriented Programming. Although the Java does not permit a subclass to be formed be inheritance from more than one parent class, several approximations to the concept are possible. Example of this type is Hole class defined as; class Hole extends Ball implements PinBallTarget{ // body of class }
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37. 2 . Multi Level Inheritance 3. Multiple Inheritance SUPER SUB SUB SUB SUPER 1 SUPER 2 extends extends implements SUB SUPER 1 SUPER 2 implements SUB extends
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60.
  • 61.
  • 62.
  • 63.
  • 64.
  • 65.
  • 66.