SlideShare a Scribd company logo
1 of 18
Prepared by
Object Oriented Programming
Dr.Sasmita Pani
Asst. Prof., GIFT
What is OOPs?
 Object-Oriented Programming is a
methodology or paradigm to design a program
using classes and objects.
 It simplifies the software development and
maintenance by providing some concepts:
 Object
 Class
 Inheritance
 Polymorphism
 Abstraction
 Encapsulation
 Message Passing
2
Object?
 Objects are key to understanding object-
oriented technology. Look around right now and you'll
find many examples of real-world objects: your dog,
your desk, your television set, your bicycle.
 Real-world objects share two characteristics: They all
have state and behavior.
 Identifying the state and behavior for real-world
objects is a great way to begin thinking in terms of
object-oriented programming.
 Dogs have state (name, color, breed, hungry) and
behavior (barking, fetching, wagging tail). Bicycles
also have state (current gear, current pedal cadence,
current speed) and behavior (changing gear,
changing pedal cadence, applying brakes).
3
Object?
 Software objects are conceptually similar to real-
world objects: they too consist of state and
related behavior.
 An object stores its state in fields (variables in
some programming languages) and exposes its
behavior through methods (functions in some
programming languages).
 Methods operate on an object's internal state and
serve as the primary mechanism for object-to-
object communication.
4
Object?
A bicycle modeled as a software
object.
A software
object.
5
Class?
 A class is the blueprint from which individual
objects are created.
 It is a logical entity.
6
Class by Example
 In the real world, you'll often find many individual
objects all of the same kind.
 There may be thousands of other bicycles in
existence, all of the same make and model.
 Each bicycle was built from the same set of
blueprints and therefore contains the same
components.
 In object-oriented terms, we say that your bicycle
is an instance of the class of objects known as
bicycles
7
Class by Example
Syntax
modifier class myClass
{ //class header //field,
constructor //method
declarations
}
public class Dog
{
String breed;
int age; String color;
void barking() { }
void hungry() { }
void sleeping() { }
}
8
Abstraction
9
 Hiding internal details and showing functionality is
known as abstraction. For example: phone call, we don't
know the internal processing.
 In java, we use abstract class and interface to achieve
abstraction.
Example
 Let's take one real life example of a TV, which you can turn
on and off, change the channel, adjust the volume, and
add external components such as speakers, VCRs, and
DVD players, BUT you do not know its internal details, that
is, you do not know how it receives signals over the air or
through a cable, how it translates them, and finally displays
them on the screen.
 Thus, we can say a television clearly separates its internal
implementation from its external interface and you can play
with its interfaces like the power button, channel changer,
and volume control without having any knowledge of its
internals.
Encapsulation
10
 Binding (or wrapping) code and data together
into a single unit is known as encapsulation.
For example: capsule, it is wrapped with different
medicines.
 A java class is the example of encapsulation.
Java bean is the fully encapsulated class
because all the data members are private here.
Inheritance?
 When one object acquires all the properties
and behaviors of parent object i.e. known as
inheritance.
 It provides code reusability. It is used to achieve
runtime polymorphism.
 Object-oriented programming allows classes
to inherit commonly used state and behavior from
other classes.
11
Inheritance?
In this example, Bicycle now becomes the superclass of
MountainBike, RoadBike, and TandemBike. In 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:
12
Inheriting Syntax
 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
// a mountain bike would go here
}
13
Interface?
 An interface is a group of related methods with
empty bodies.
 Methods form the object's interface with the
outside world; the buttons on the front of your
television set, for example, are the interface
between you and the electrical wiring on the other
side of its plastic casing. You press the "power"
button to turn the television on and off.
 Interfaces form a contract between the class and
the outside world, and this contract is enforced at
build time by the compiler.
14
Interface?
 The interface in java is a mechanism to achieve
fully abstraction.
 There can be only abstract methods in the java
interface not method body.
 It is used to achieve fully abstraction and multiple
inheritance in Java.
 Java Interface also represents IS-A
relationship.
 It cannot be instantiated just like abstract class.
15
Package?
 A package is a namespace that organizes a set of
related classes and interfaces.
 Conceptually you can think of packages as being
similar to different folders on your computer.
 The Java platform provides an enormous class
library (a set of packages) suitable for use in your
own applications. This library is known as the
"Application Programming Interface", or "API" for
short.
 Its packages represent the tasks most commonly
associated with general-purpose programming.
16
Polymorphism?
 When one task is performed by different
ways i.e. known as polymorphism. For example:
to convince the customer differently, to draw
something e.g. shape or rectangle etc.
 In java, we use method overloading and method
overriding to achieve polymorphism.
 Another example can be to speak something e.g.
cat speaks meaw, dog barks woof etc.
17
18

More Related Content

Similar to Introduction to OOP.pptx

Similar to Introduction to OOP.pptx (20)

FAL(2022-23)_CSE0206_ETH_AP2022232000455_Reference_Material_I_16-Aug-2022_Mod...
FAL(2022-23)_CSE0206_ETH_AP2022232000455_Reference_Material_I_16-Aug-2022_Mod...FAL(2022-23)_CSE0206_ETH_AP2022232000455_Reference_Material_I_16-Aug-2022_Mod...
FAL(2022-23)_CSE0206_ETH_AP2022232000455_Reference_Material_I_16-Aug-2022_Mod...
 
Java PPT
Java PPTJava PPT
Java PPT
 
Md02 - Getting Started part-2
Md02 - Getting Started part-2Md02 - Getting Started part-2
Md02 - Getting Started part-2
 
javaopps concepts
javaopps conceptsjavaopps concepts
javaopps concepts
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
PROGRAMMING IN JAVA unit 1.pptx
PROGRAMMING IN JAVA unit 1.pptxPROGRAMMING IN JAVA unit 1.pptx
PROGRAMMING IN JAVA unit 1.pptx
 
Java OOPS Concept
Java OOPS ConceptJava OOPS Concept
Java OOPS Concept
 
2 oop
2 oop2 oop
2 oop
 
Java OOP Concept
Java OOP ConceptJava OOP Concept
Java OOP Concept
 
Presentation on oo ps 2
Presentation on oo ps 2Presentation on oo ps 2
Presentation on oo ps 2
 
Programming Laboratory Unit 1.pdf
Programming Laboratory Unit 1.pdfProgramming Laboratory Unit 1.pdf
Programming Laboratory Unit 1.pdf
 
ITFT - Oops
ITFT - OopsITFT - Oops
ITFT - Oops
 
Object-Oriented Programming in Java.pdf
Object-Oriented Programming in Java.pdfObject-Oriented Programming in Java.pdf
Object-Oriented Programming in Java.pdf
 
Ah java-ppt2
Ah java-ppt2Ah java-ppt2
Ah java-ppt2
 
ITTutor Advanced Java (1).pptx
ITTutor Advanced Java (1).pptxITTutor Advanced Java (1).pptx
ITTutor Advanced Java (1).pptx
 
Java notes jkuat it
Java notes jkuat itJava notes jkuat it
Java notes jkuat it
 
Java notes(OOP) jkuat IT esection
Java notes(OOP) jkuat IT esectionJava notes(OOP) jkuat IT esection
Java notes(OOP) jkuat IT esection
 
Mca 504 dotnet_unit3
Mca 504 dotnet_unit3Mca 504 dotnet_unit3
Mca 504 dotnet_unit3
 
Core java
Core javaCore java
Core java
 
Object And Oriented Programing ( Oop ) Languages
Object And Oriented Programing ( Oop ) LanguagesObject And Oriented Programing ( Oop ) Languages
Object And Oriented Programing ( Oop ) Languages
 

Recently uploaded

Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)dollysharma2066
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfAsst.prof M.Gokilavani
 
Comparative Analysis of Text Summarization Techniques
Comparative Analysis of Text Summarization TechniquesComparative Analysis of Text Summarization Techniques
Comparative Analysis of Text Summarization Techniquesugginaramesh
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...asadnawaz62
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
 
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncWhy does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncssuser2ae721
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor CatchersTechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catcherssdickerson1
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEroselinkalist12
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfAsst.prof M.Gokilavani
 

Recently uploaded (20)

Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
Comparative Analysis of Text Summarization Techniques
Comparative Analysis of Text Summarization TechniquesComparative Analysis of Text Summarization Techniques
Comparative Analysis of Text Summarization Techniques
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
young call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Serviceyoung call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Service
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
 
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncWhy does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor CatchersTechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
 

Introduction to OOP.pptx

  • 1. Prepared by Object Oriented Programming Dr.Sasmita Pani Asst. Prof., GIFT
  • 2. What is OOPs?  Object-Oriented Programming is a methodology or paradigm to design a program using classes and objects.  It simplifies the software development and maintenance by providing some concepts:  Object  Class  Inheritance  Polymorphism  Abstraction  Encapsulation  Message Passing 2
  • 3. Object?  Objects are key to understanding object- oriented technology. Look around right now and you'll find many examples of real-world objects: your dog, your desk, your television set, your bicycle.  Real-world objects share two characteristics: They all have state and behavior.  Identifying the state and behavior for real-world objects is a great way to begin thinking in terms of object-oriented programming.  Dogs have state (name, color, breed, hungry) and behavior (barking, fetching, wagging tail). Bicycles also have state (current gear, current pedal cadence, current speed) and behavior (changing gear, changing pedal cadence, applying brakes). 3
  • 4. Object?  Software objects are conceptually similar to real- world objects: they too consist of state and related behavior.  An object stores its state in fields (variables in some programming languages) and exposes its behavior through methods (functions in some programming languages).  Methods operate on an object's internal state and serve as the primary mechanism for object-to- object communication. 4
  • 5. Object? A bicycle modeled as a software object. A software object. 5
  • 6. Class?  A class is the blueprint from which individual objects are created.  It is a logical entity. 6
  • 7. Class by Example  In the real world, you'll often find many individual objects all of the same kind.  There may be thousands of other bicycles in existence, all of the same make and model.  Each bicycle was built from the same set of blueprints and therefore contains the same components.  In object-oriented terms, we say that your bicycle is an instance of the class of objects known as bicycles 7
  • 8. Class by Example Syntax modifier class myClass { //class header //field, constructor //method declarations } public class Dog { String breed; int age; String color; void barking() { } void hungry() { } void sleeping() { } } 8
  • 9. Abstraction 9  Hiding internal details and showing functionality is known as abstraction. For example: phone call, we don't know the internal processing.  In java, we use abstract class and interface to achieve abstraction. Example  Let's take one real life example of a TV, which you can turn on and off, change the channel, adjust the volume, and add external components such as speakers, VCRs, and DVD players, BUT you do not know its internal details, that is, you do not know how it receives signals over the air or through a cable, how it translates them, and finally displays them on the screen.  Thus, we can say a television clearly separates its internal implementation from its external interface and you can play with its interfaces like the power button, channel changer, and volume control without having any knowledge of its internals.
  • 10. Encapsulation 10  Binding (or wrapping) code and data together into a single unit is known as encapsulation. For example: capsule, it is wrapped with different medicines.  A java class is the example of encapsulation. Java bean is the fully encapsulated class because all the data members are private here.
  • 11. Inheritance?  When one object acquires all the properties and behaviors of parent object i.e. known as inheritance.  It provides code reusability. It is used to achieve runtime polymorphism.  Object-oriented programming allows classes to inherit commonly used state and behavior from other classes. 11
  • 12. Inheritance? In this example, Bicycle now becomes the superclass of MountainBike, RoadBike, and TandemBike. In 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: 12
  • 13. Inheriting Syntax  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 // a mountain bike would go here } 13
  • 14. Interface?  An interface is a group of related methods with empty bodies.  Methods form the object's interface with the outside world; the buttons on the front of your television set, for example, are the interface between you and the electrical wiring on the other side of its plastic casing. You press the "power" button to turn the television on and off.  Interfaces form a contract between the class and the outside world, and this contract is enforced at build time by the compiler. 14
  • 15. Interface?  The interface in java is a mechanism to achieve fully abstraction.  There can be only abstract methods in the java interface not method body.  It is used to achieve fully abstraction and multiple inheritance in Java.  Java Interface also represents IS-A relationship.  It cannot be instantiated just like abstract class. 15
  • 16. Package?  A package is a namespace that organizes a set of related classes and interfaces.  Conceptually you can think of packages as being similar to different folders on your computer.  The Java platform provides an enormous class library (a set of packages) suitable for use in your own applications. This library is known as the "Application Programming Interface", or "API" for short.  Its packages represent the tasks most commonly associated with general-purpose programming. 16
  • 17. Polymorphism?  When one task is performed by different ways i.e. known as polymorphism. For example: to convince the customer differently, to draw something e.g. shape or rectangle etc.  In java, we use method overloading and method overriding to achieve polymorphism.  Another example can be to speak something e.g. cat speaks meaw, dog barks woof etc. 17
  • 18. 18