SlideShare a Scribd company logo
Assignment
BY: :
Mr. Akhilesh Deshmukh
Core Java
Object Oriented Programming Concepts
Topic: Inheritance and Polymorphism
Q. What is OOPs?
• Object-oriented programming (OOP) is a way to organize and
conceptualize a program as a set of interacting objects.
• The key idea :- The real world can be accurately described as a
collection of objects that interact with each other.
Object Oriented vs. Structured Language
Object Oriented
• Based on Objects
• It includes approach in the form of
Encapsulation, Inheritance,
Polymorphism and Abstraction
• Vast Reusability
Ex. Java, C++, Python, and Ruby
Structured Language
• No Objects
• Procedural approach in the form of
functions
• Top-Down design
• Limited Reusability
Ex. C, Pascal, and Fortran
Why
OOPs ?
• Increases Productivity
Code Reusability
• Easier Integration
Adaptability
• Affordable and easy to Maintain
Cost Effective
• Objects and Classes can be tested Independently
Easy Debugging
• Allows for the organization and management of
large codebases
Scalability
• Access to Objects can be
restricted(Encapsulation)
Modularity
Pillars of OOPs Inheritance Polymorphism
Abstraction Encapsulation
Inheritance
Q. What is Inheritance ?
Literally it means Inheriting something from one person to other i.e.
Property from grandfather to father and father to son.
Grandfather’s
property
(G)
Father’s
property
(F+G)
Son’s property
(S+F+G)
Inheritance
How ?
• Derives a new class from existing one.
• Existing class is called a Parent-class or
Super class.
• Derived class is called is Child-class or
Sub-class.
• Achieved through “extends” keyword.
• Java supports single and Multi-level
Inheritance.
Exception:
Java does not support Multiple
Inheritance To prevent Ambiguity
but can be achieved through Interface.
public class Country
{
public void country()
{
System.out.println(“
Country – India”);
}
}
public class State extends
Country
{
public void state()
{
System.out.println(“
State-maharashtra ”);
}
}
public class City extends
State
{
public void city()
{
System.out.println(“
City-Pune”);
}
}
public class Test
{
public static void main(String [] args)
{
City c=new City();
c.country();
c.state();
c.city();}
}
output
Country-India
State-Maharashtra
City-Pune
Polymorphism
Q. What is Polymorphism?
• Literally it means One name many forms.
• Allows objects of different classes to be treated as objects of a common superclass
• It is closely related to inheritance and method overriding.
• Achieved through 1) Overriding (Dynamic binding)
2) Overloading (Static Binding)
• Polymorphism allows you to write more flexible
and extensible code
Flexibility and
Extensibility:
• Subclasses can override or extend the behavior
of the parent class, reducing code duplication
Code Reusability
• more readable and self-explanatory
• expresses the intent more clearly.
Enhances
Readability
• allows you to have a single method name with
different implementations
Simplifies Method
Overloading
WHY ?
Polymorphism
Polymorphism How ?
Overloading
• Multiple methods in the same class
with the same name but different
parameter lists
• Determined at compile-time (static
binding)
• Only within the same class.
• Can have the same or different
return types
Override
• Used in inheritance to provide a specific
implementation of a method in a
subclass that is already defined in its
superclass
• Determined at runtime (dynamic
binding)
• A method in a subclass with the same
name, return type, and parameter
must be same to Superclass
• Requires the same return type
Compile-Time Polymorphism
(Static Binding)
Run-Time Polymorphism
(Dynamic Binding)
public class Addition{
public int add(int a, int b) {
return a + b; }
public double add(double a, double b) {
return a + b; }
public static void main(String[] args)
{
Addition a=new Addition();
a.add(11111111,44444444);
} }
Output:
555555555
public class Animal {
public void bark() {
System.out.println("Animal barks"); } }
public class Dog extends Animal {
@Override
public void bark() {
System.out.println("Dog barks"); } }
public class Test{
public static void main(String [] args){
Dog d=new Dog();
d.bark();}}
Output:
Dog barks

More Related Content

Similar to AkhileshD_Presentation_Core_Java_OOPs.pptx

OOPS – General Understanding in .NET
OOPS – General Understanding in .NETOOPS – General Understanding in .NET
OOPS – General Understanding in .NETSabith Byari
 
Intro to oop.pptx
Intro to oop.pptxIntro to oop.pptx
Intro to oop.pptxUmerUmer25
 
Design Pattern lecture 1
Design Pattern lecture 1Design Pattern lecture 1
Design Pattern lecture 1Julie Iskander
 
Need of object oriented programming
Need of object oriented programmingNeed of object oriented programming
Need of object oriented programmingAmar Jukuntla
 
Features of Object Oriented Programming.pptx
Features of Object Oriented Programming.pptxFeatures of Object Oriented Programming.pptx
Features of Object Oriented Programming.pptxSwagatoBiswas
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programmingVasilios Kuznos
 
1unit-120324103142-phpapp02.pdf
1unit-120324103142-phpapp02.pdf1unit-120324103142-phpapp02.pdf
1unit-120324103142-phpapp02.pdfSahajShrimal1
 
C++ in object oriented programming
C++ in object oriented programmingC++ in object oriented programming
C++ in object oriented programmingSaket Khopkar
 
Polymorphism
PolymorphismPolymorphism
PolymorphismNuha Noor
 
What is OOP_ (Object Oriented Programming) (1).pptx
What is OOP_ (Object Oriented Programming) (1).pptxWhat is OOP_ (Object Oriented Programming) (1).pptx
What is OOP_ (Object Oriented Programming) (1).pptxhreempandya
 
What are some key topics and concepts that candidates are commonly expected t...
What are some key topics and concepts that candidates are commonly expected t...What are some key topics and concepts that candidates are commonly expected t...
What are some key topics and concepts that candidates are commonly expected t...DivyanshWsCube
 

Similar to AkhileshD_Presentation_Core_Java_OOPs.pptx (20)

OOPS – General Understanding in .NET
OOPS – General Understanding in .NETOOPS – General Understanding in .NET
OOPS – General Understanding in .NET
 
Intro to oop.pptx
Intro to oop.pptxIntro to oop.pptx
Intro to oop.pptx
 
Design Pattern lecture 1
Design Pattern lecture 1Design Pattern lecture 1
Design Pattern lecture 1
 
Need of object oriented programming
Need of object oriented programmingNeed of object oriented programming
Need of object oriented programming
 
Features of Object Oriented Programming.pptx
Features of Object Oriented Programming.pptxFeatures of Object Oriented Programming.pptx
Features of Object Oriented Programming.pptx
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
Principles of OOPs.pptx
Principles of OOPs.pptxPrinciples of OOPs.pptx
Principles of OOPs.pptx
 
oop.pptx
oop.pptxoop.pptx
oop.pptx
 
C sharp
C sharpC sharp
C sharp
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
1unit-120324103142-phpapp02.pdf
1unit-120324103142-phpapp02.pdf1unit-120324103142-phpapp02.pdf
1unit-120324103142-phpapp02.pdf
 
C++ in object oriented programming
C++ in object oriented programmingC++ in object oriented programming
C++ in object oriented programming
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
 
What is OOP_ (Object Oriented Programming) (1).pptx
What is OOP_ (Object Oriented Programming) (1).pptxWhat is OOP_ (Object Oriented Programming) (1).pptx
What is OOP_ (Object Oriented Programming) (1).pptx
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
General oop concept
General oop conceptGeneral oop concept
General oop concept
 
Introduction
IntroductionIntroduction
Introduction
 
Java session2
Java session2Java session2
Java session2
 
What are some key topics and concepts that candidates are commonly expected t...
What are some key topics and concepts that candidates are commonly expected t...What are some key topics and concepts that candidates are commonly expected t...
What are some key topics and concepts that candidates are commonly expected t...
 
2CPP19 - Summation
2CPP19 - Summation2CPP19 - Summation
2CPP19 - Summation
 

Recently uploaded

Studiovity film pre-production and screenwriting software
Studiovity film pre-production and screenwriting softwareStudiovity film pre-production and screenwriting software
Studiovity film pre-production and screenwriting softwareinfo611746
 
Designing for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web ServicesDesigning for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web ServicesKrzysztofKkol1
 
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...rajkumar669520
 
INGKA DIGITAL: Linked Metadata by Design
INGKA DIGITAL: Linked Metadata by DesignINGKA DIGITAL: Linked Metadata by Design
INGKA DIGITAL: Linked Metadata by DesignNeo4j
 
Workforce Efficiency with Employee Time Tracking Software.pdf
Workforce Efficiency with Employee Time Tracking Software.pdfWorkforce Efficiency with Employee Time Tracking Software.pdf
Workforce Efficiency with Employee Time Tracking Software.pdfDeskTrack
 
CompTIA Security+ (Study Notes) for cs.pdf
CompTIA Security+ (Study Notes) for cs.pdfCompTIA Security+ (Study Notes) for cs.pdf
CompTIA Security+ (Study Notes) for cs.pdfFurqanuddin10
 
Implementing KPIs and Right Metrics for Agile Delivery Teams.pdf
Implementing KPIs and Right Metrics for Agile Delivery Teams.pdfImplementing KPIs and Right Metrics for Agile Delivery Teams.pdf
Implementing KPIs and Right Metrics for Agile Delivery Teams.pdfVictor Lopez
 
GraphAware - Transforming policing with graph-based intelligence analysis
GraphAware - Transforming policing with graph-based intelligence analysisGraphAware - Transforming policing with graph-based intelligence analysis
GraphAware - Transforming policing with graph-based intelligence analysisNeo4j
 
OpenChain @ LF Japan Executive Briefing - May 2024
OpenChain @ LF Japan Executive Briefing - May 2024OpenChain @ LF Japan Executive Briefing - May 2024
OpenChain @ LF Japan Executive Briefing - May 2024Shane Coughlan
 
10 Essential Software Testing Tools You Need to Know About.pdf
10 Essential Software Testing Tools You Need to Know About.pdf10 Essential Software Testing Tools You Need to Know About.pdf
10 Essential Software Testing Tools You Need to Know About.pdfkalichargn70th171
 
De mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FMEDe mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FMEJelle | Nordend
 
AI/ML Infra Meetup | ML explainability in Michelangelo
AI/ML Infra Meetup | ML explainability in MichelangeloAI/ML Infra Meetup | ML explainability in Michelangelo
AI/ML Infra Meetup | ML explainability in MichelangeloAlluxio, Inc.
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar
 
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?XfilesPro
 
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAGAI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAGAlluxio, Inc.
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandIES VE
 
Crafting the Perfect Measurement Sheet with PLM Integration
Crafting the Perfect Measurement Sheet with PLM IntegrationCrafting the Perfect Measurement Sheet with PLM Integration
Crafting the Perfect Measurement Sheet with PLM IntegrationWave PLM
 
JustNaik Solution Deck (stage bus sector)
JustNaik Solution Deck (stage bus sector)JustNaik Solution Deck (stage bus sector)
JustNaik Solution Deck (stage bus sector)Max Lee
 
Benefits of Employee Monitoring Software
Benefits of  Employee Monitoring SoftwareBenefits of  Employee Monitoring Software
Benefits of Employee Monitoring SoftwareMera Monitor
 

Recently uploaded (20)

Studiovity film pre-production and screenwriting software
Studiovity film pre-production and screenwriting softwareStudiovity film pre-production and screenwriting software
Studiovity film pre-production and screenwriting software
 
Top Mobile App Development Companies 2024
Top Mobile App Development Companies 2024Top Mobile App Development Companies 2024
Top Mobile App Development Companies 2024
 
Designing for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web ServicesDesigning for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web Services
 
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
 
INGKA DIGITAL: Linked Metadata by Design
INGKA DIGITAL: Linked Metadata by DesignINGKA DIGITAL: Linked Metadata by Design
INGKA DIGITAL: Linked Metadata by Design
 
Workforce Efficiency with Employee Time Tracking Software.pdf
Workforce Efficiency with Employee Time Tracking Software.pdfWorkforce Efficiency with Employee Time Tracking Software.pdf
Workforce Efficiency with Employee Time Tracking Software.pdf
 
CompTIA Security+ (Study Notes) for cs.pdf
CompTIA Security+ (Study Notes) for cs.pdfCompTIA Security+ (Study Notes) for cs.pdf
CompTIA Security+ (Study Notes) for cs.pdf
 
Implementing KPIs and Right Metrics for Agile Delivery Teams.pdf
Implementing KPIs and Right Metrics for Agile Delivery Teams.pdfImplementing KPIs and Right Metrics for Agile Delivery Teams.pdf
Implementing KPIs and Right Metrics for Agile Delivery Teams.pdf
 
GraphAware - Transforming policing with graph-based intelligence analysis
GraphAware - Transforming policing with graph-based intelligence analysisGraphAware - Transforming policing with graph-based intelligence analysis
GraphAware - Transforming policing with graph-based intelligence analysis
 
OpenChain @ LF Japan Executive Briefing - May 2024
OpenChain @ LF Japan Executive Briefing - May 2024OpenChain @ LF Japan Executive Briefing - May 2024
OpenChain @ LF Japan Executive Briefing - May 2024
 
10 Essential Software Testing Tools You Need to Know About.pdf
10 Essential Software Testing Tools You Need to Know About.pdf10 Essential Software Testing Tools You Need to Know About.pdf
10 Essential Software Testing Tools You Need to Know About.pdf
 
De mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FMEDe mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FME
 
AI/ML Infra Meetup | ML explainability in Michelangelo
AI/ML Infra Meetup | ML explainability in MichelangeloAI/ML Infra Meetup | ML explainability in Michelangelo
AI/ML Infra Meetup | ML explainability in Michelangelo
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
 
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
 
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAGAI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
 
Crafting the Perfect Measurement Sheet with PLM Integration
Crafting the Perfect Measurement Sheet with PLM IntegrationCrafting the Perfect Measurement Sheet with PLM Integration
Crafting the Perfect Measurement Sheet with PLM Integration
 
JustNaik Solution Deck (stage bus sector)
JustNaik Solution Deck (stage bus sector)JustNaik Solution Deck (stage bus sector)
JustNaik Solution Deck (stage bus sector)
 
Benefits of Employee Monitoring Software
Benefits of  Employee Monitoring SoftwareBenefits of  Employee Monitoring Software
Benefits of Employee Monitoring Software
 

AkhileshD_Presentation_Core_Java_OOPs.pptx

  • 2. Core Java Object Oriented Programming Concepts Topic: Inheritance and Polymorphism
  • 3. Q. What is OOPs? • Object-oriented programming (OOP) is a way to organize and conceptualize a program as a set of interacting objects. • The key idea :- The real world can be accurately described as a collection of objects that interact with each other.
  • 4. Object Oriented vs. Structured Language Object Oriented • Based on Objects • It includes approach in the form of Encapsulation, Inheritance, Polymorphism and Abstraction • Vast Reusability Ex. Java, C++, Python, and Ruby Structured Language • No Objects • Procedural approach in the form of functions • Top-Down design • Limited Reusability Ex. C, Pascal, and Fortran
  • 5. Why OOPs ? • Increases Productivity Code Reusability • Easier Integration Adaptability • Affordable and easy to Maintain Cost Effective • Objects and Classes can be tested Independently Easy Debugging • Allows for the organization and management of large codebases Scalability • Access to Objects can be restricted(Encapsulation) Modularity
  • 6. Pillars of OOPs Inheritance Polymorphism Abstraction Encapsulation
  • 7. Inheritance Q. What is Inheritance ? Literally it means Inheriting something from one person to other i.e. Property from grandfather to father and father to son. Grandfather’s property (G) Father’s property (F+G) Son’s property (S+F+G)
  • 8. Inheritance How ? • Derives a new class from existing one. • Existing class is called a Parent-class or Super class. • Derived class is called is Child-class or Sub-class. • Achieved through “extends” keyword. • Java supports single and Multi-level Inheritance. Exception: Java does not support Multiple Inheritance To prevent Ambiguity but can be achieved through Interface.
  • 9. public class Country { public void country() { System.out.println(“ Country – India”); } } public class State extends Country { public void state() { System.out.println(“ State-maharashtra ”); } } public class City extends State { public void city() { System.out.println(“ City-Pune”); } } public class Test { public static void main(String [] args) { City c=new City(); c.country(); c.state(); c.city();} } output Country-India State-Maharashtra City-Pune
  • 10. Polymorphism Q. What is Polymorphism? • Literally it means One name many forms. • Allows objects of different classes to be treated as objects of a common superclass • It is closely related to inheritance and method overriding. • Achieved through 1) Overriding (Dynamic binding) 2) Overloading (Static Binding)
  • 11. • Polymorphism allows you to write more flexible and extensible code Flexibility and Extensibility: • Subclasses can override or extend the behavior of the parent class, reducing code duplication Code Reusability • more readable and self-explanatory • expresses the intent more clearly. Enhances Readability • allows you to have a single method name with different implementations Simplifies Method Overloading WHY ? Polymorphism
  • 12. Polymorphism How ? Overloading • Multiple methods in the same class with the same name but different parameter lists • Determined at compile-time (static binding) • Only within the same class. • Can have the same or different return types Override • Used in inheritance to provide a specific implementation of a method in a subclass that is already defined in its superclass • Determined at runtime (dynamic binding) • A method in a subclass with the same name, return type, and parameter must be same to Superclass • Requires the same return type
  • 13. Compile-Time Polymorphism (Static Binding) Run-Time Polymorphism (Dynamic Binding) public class Addition{ public int add(int a, int b) { return a + b; } public double add(double a, double b) { return a + b; } public static void main(String[] args) { Addition a=new Addition(); a.add(11111111,44444444); } } Output: 555555555 public class Animal { public void bark() { System.out.println("Animal barks"); } } public class Dog extends Animal { @Override public void bark() { System.out.println("Dog barks"); } } public class Test{ public static void main(String [] args){ Dog d=new Dog(); d.bark();}} Output: Dog barks