SlideShare a Scribd company logo
1 of 29
Download to read offline
Introduction to
Object Oriented Programming
Gayathri Namasivayam
Introduction to OOP
Topics
●Why use OOP?
●Building blocks of OOP
● Classes
● Objects
●What is OOP?
●OOP concepts
● Abstraction
● Encapsulation
● Inheritance
● Polymorphism
●Advantages vs Disadvantages
●Conclusion
Introduction to OOP
Topics
●Why use OOP?
●Building blocks of OOP
● Classes
● Objects
●What is OOP?
●OOP concepts
● Abstraction
● Encapsulation
● Inheritance
● Polymorphism
●Advantages vs Disadvantages
●Conclusion
Introduction to OOP
Why use OOP?
●Object Oriented Programming (OOP) is one of the most
widely used programming paradigm
●Why is it extensively used?
● Well suited for building trivial and complex applications
● Allows re-use of code thereby increasing productivity
● New features can be easily built into the existing code
● Reduced production cost and maintenance cost
●Common programming languages used for OOP include
C++, Java, and C#
Introduction to OOP
Topics
●Why use OOP?
●Building blocks of OOP
● Classes
● Objects
●What is OOP?
●OOP concepts
● Abstraction
● Encapsulation
● Inheritance
● Polymorphism
●Advantages vs Disadvantages
●Conclusion
Introduction to OOP
Building Blocks of OOP: Objects &
Classes
●Object: models a
● Real world object (ex. computer, book, box)
● Concept (ex. meeting, interview)
● Process (ex. sorting a stack of papers or comparing two
computers to measure their performance)
●Class: prototype or blueprint from which objects are
created
Introduction to OOP
Building Blocks of OOP: Objects &
Classes
●Class has
● Set of attributes or properties that describes every object
● Set of behavior or actions that every object can perform
●Object has
● Set of data (value for each of its attribute)
● Set of actions that it can perform
● An identity
●Every object belongs to a class
Introduction to OOP
Real World Example of Objects &
Classes
Object: FordCar1
Behavior
Start, Accelerate,
Reverse, Stop
Attributes
Color: Yellow
Type: Coupe
Model: Mustang
Cylinder: 6
Attributes
Color, Type, Model, Cylinder
Behavior
Start, Accelerate, Reverse, Stop
Class: FordCar
Behavior
Start, Accelerate,
Reverse, Stop
Attributes
Color: Orange
Type: Coupe
Model: Focus
Cylinder: 4
Object: FordCar2
Introduction to OOP
Another Real World Example..
Attributes
Name, Height, Age
Behavior
Speak, Listen, Eat, Run, Walk
Class: Person
Object: Person1
Attributes
Name: Ann
Height: 5’ 4”
Age: 21
Behavior
Speak,
Listen, Eat,
Run, Walk
Attributes
Name: Adam
Height: 5’ 9”
Age: 24
Behavior
Speak,
Listen, Eat,
Run, Walk
Object: Person2
Introduction to OOP
Class
●A class is a set of variables (to represent its attributes) and
functions (to describe its behavior) that act on its variables
Introduction to OOP
Class ShippingBox
int shipping_cost() {
return cost_per_pound*weight;
}
sender_name : string
receiver_name : string
cost_per_pound : int
weight : int
shipping_cost() : int
Introduction to OOP
Object
●Object is an instance of a class that holds data (values) in
its variables. Data can be accessed by its functions
Introduction to OOP
Objects of ShippingBox class
sender_name = Jim
receiver_name = John
cost_per_pound = 5
weight = 10
shipping_cost()
Object BoxB
Object BoxA
sender_name = Julie
receiver_name = Jill
cost_per_pound = 2
weight = 5
shipping_cost()
Class
ShippingBox
Introduction to OOP
Topics
●Why use OOP?
●Building blocks of OOP
● Classes
● Objects
●What is OOP?
●OOP concepts
● Abstraction
● Encapsulation
● Inheritance
● Polymorphism
●Advantages vs Disadvantages
●Conclusion
Introduction to OOP
What is OOP?
●Paradigm for problem solving by interaction among objects
●It follows a natural way of solving problems
● Ex. Ann wants to start her car
(1) Ann walks to her car
(2) Ann sends a message to the car to start by turning on the ignition
(3)The car starts
Introduction to OOP
Problem Solving in OOP
Problem: Ann wants to start her car
Name = Ann
Age = 21
Speak()
Run()
Walk()
Object Ann
Color = Yellow
Type = Coupe
Model = Mustang
Cylinder = 6
Start()
Accelerate()
Stop()
Object Ann’s car
message
Introduction to OOP
Topics
●Why use OOP?
●Building blocks of OOP
● Classes
● Objects
●What is OOP?
●OOP concepts
● Abstraction
● Encapsulation
● Inheritance
● Polymorphism
●Advantages vs Disadvantages
●Conclusion
Introduction to OOP
Abstraction
●Extracting essential properties and behavior of an entity
●Class represents such an abstraction and is commonly
referred to as an abstract data type
Ex. In an application that computes the shipping cost of a
box, we extract its properties: cost_per_pound, weight and
its behavior: shipping_cost()
Introduction to OOP
Abstraction
sender_name : string
receiver_name : string
cost_per_pound : int
weight : int
shipping_cost() : int
Class
Shipping Box
Attributes
Sender’s name,
Receiver’s name,
Cost of shipping per pound,
Weight
Behavior
Calculate shipping cost
Abstraction
Introduction to OOP
Topics
●Why use OOP?
●Building blocks of OOP
● Classes
● Objects
●What is OOP?
●OOP concepts
● Abstraction
● Encapsulation
● Inheritance
● Polymorphism
●Advantages vs Disadvantages
●Conclusion
Introduction to OOP
Encapsulation
sender_name
receiver_name
cost_per_pound
weight
shipping_cost()
●Mechanism by which we combine data and the functions
that manipulate the data into one unit
●Objects & Classes enforce encapsulation
Introduction to OOP
Topics
●Why use OOP?
●Building blocks of OOP
● Classes
● Objects
●What is OOP?
●OOP concepts
● Abstraction
● Encapsulation
● Inheritance
● Polymorphism
●Advantages vs Disadvantages
●Conclusion
Introduction to OOP
Inheritance
●Create new classes (derived classes) from existing classes
(base classes)
●The derived class inherits the variables and functions of
the base class and adds additional ones!
●Provides the ability to re-use existing code
Introduction to OOP
Inheritance Example
BankAccount CheckingAccount SavingsAccount
customer_name : string
account_type : string
balance : int
insufficient_funds_fee : int
deposit() : int
withdrawal() : int
process_deposit() : int
customer_name : string
account_type : string
balance : int
deposit() : int
withdrawal() : int
customer_name : string
account_type : string
balance : int
interest_rate : int
deposit() : int
withdrawal() : int
calculate_interest() : int
Introduction to OOP
Inheritance Example
interest_rate : int
calculate_interest() : int
insufficient_funds_fee : int
process_deposit() : int
CheckingAccount SavingsAccount
customer_name : string
account_type : string
balance : int
deposit() : int
withdrawal() : int
BankAccount
Introduction to OOP
Topics
●Why use OOP?
●Building blocks of OOP
● Classes
● Objects
●What is OOP?
●OOP concepts
● Abstraction
● Encapsulation
● Inheritance
● Polymorphism*
●Advantages vs Disadvantages
●Conclusion
(* To be covered in the next class)
Introduction to OOP
Disadvantages of OOP
●Initial extra effort needed in accurately modeling the
classes and sub-classes for a problem
●Suited for modeling certain real world problems as
opposed to some others
Introduction to OOP
Conclusion
●Classes & Objects
●Concepts in OOP
● Abstraction
● Encapsulation
● Inheritance
●Advantages & Disadvantages
●Next class
● Be prepared for an in-class activity (based on topics covered
today)!
● Polymorphism in OOP!
Introduction to OOP
Thank you!
Introduction to OOP

More Related Content

Similar to Object Oriented Programming_combined.ppt.pdf

introduction of Object oriented programming
introduction of Object oriented programmingintroduction of Object oriented programming
introduction of Object oriented programmingRiturajJain8
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programmingMH Abid
 
PHP OOP Lecture - 01.pptx
PHP OOP Lecture - 01.pptxPHP OOP Lecture - 01.pptx
PHP OOP Lecture - 01.pptxAtikur Rahman
 
Object oriented programming in java
Object oriented programming in javaObject oriented programming in java
Object oriented programming in javaElizabeth alexander
 
OOPS in java | Super and this Keyword | Memory Management in java | pacakages...
OOPS in java | Super and this Keyword | Memory Management in java | pacakages...OOPS in java | Super and this Keyword | Memory Management in java | pacakages...
OOPS in java | Super and this Keyword | Memory Management in java | pacakages...Sagar Verma
 
Regex,functions, inheritance,class, attribute,overloding
Regex,functions, inheritance,class, attribute,overlodingRegex,functions, inheritance,class, attribute,overloding
Regex,functions, inheritance,class, attribute,overlodingsangumanikesh
 
Object Oriented Programming Constructors & Destructors
Object Oriented Programming  Constructors &  DestructorsObject Oriented Programming  Constructors &  Destructors
Object Oriented Programming Constructors & Destructorsanitashinde33
 
Chapter1_ObjectOrientedProgramming.pptx
Chapter1_ObjectOrientedProgramming.pptxChapter1_ObjectOrientedProgramming.pptx
Chapter1_ObjectOrientedProgramming.pptxpamyasstos
 
Core Java Basics
Core Java BasicsCore Java Basics
Core Java BasicsFayis-QA
 
Introduction to oop
Introduction to oopIntroduction to oop
Introduction to oopcolleges
 
U1 JAVA.pptx
U1 JAVA.pptxU1 JAVA.pptx
U1 JAVA.pptxmadan r
 
Introduction to object oriented programming
Introduction to object oriented programmingIntroduction to object oriented programming
Introduction to object oriented programmingAbzetdin Adamov
 
ITT 202 PRINCIPLES OF OBJECT ORIENTED TECHNIQUE
ITT 202 PRINCIPLES OF OBJECT ORIENTED TECHNIQUEITT 202 PRINCIPLES OF OBJECT ORIENTED TECHNIQUE
ITT 202 PRINCIPLES OF OBJECT ORIENTED TECHNIQUEVinishA23
 

Similar to Object Oriented Programming_combined.ppt.pdf (20)

introduction of Object oriented programming
introduction of Object oriented programmingintroduction of Object oriented programming
introduction of Object oriented programming
 
Oop java
Oop javaOop java
Oop java
 
oop.pptx
oop.pptxoop.pptx
oop.pptx
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
PHP OOP Lecture - 01.pptx
PHP OOP Lecture - 01.pptxPHP OOP Lecture - 01.pptx
PHP OOP Lecture - 01.pptx
 
Object oriented programming in java
Object oriented programming in javaObject oriented programming in java
Object oriented programming in java
 
Lecture 5.pdf
Lecture 5.pdfLecture 5.pdf
Lecture 5.pdf
 
java - oop's in depth journey
java - oop's in depth journeyjava - oop's in depth journey
java - oop's in depth journey
 
Polymorphism in oop
Polymorphism in oopPolymorphism in oop
Polymorphism in oop
 
OOPS in java | Super and this Keyword | Memory Management in java | pacakages...
OOPS in java | Super and this Keyword | Memory Management in java | pacakages...OOPS in java | Super and this Keyword | Memory Management in java | pacakages...
OOPS in java | Super and this Keyword | Memory Management in java | pacakages...
 
Regex,functions, inheritance,class, attribute,overloding
Regex,functions, inheritance,class, attribute,overlodingRegex,functions, inheritance,class, attribute,overloding
Regex,functions, inheritance,class, attribute,overloding
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
Object Oriented Programming Constructors & Destructors
Object Oriented Programming  Constructors &  DestructorsObject Oriented Programming  Constructors &  Destructors
Object Oriented Programming Constructors & Destructors
 
Chapter1_ObjectOrientedProgramming.pptx
Chapter1_ObjectOrientedProgramming.pptxChapter1_ObjectOrientedProgramming.pptx
Chapter1_ObjectOrientedProgramming.pptx
 
Core Java Basics
Core Java BasicsCore Java Basics
Core Java Basics
 
Introduction to oop
Introduction to oopIntroduction to oop
Introduction to oop
 
U1 JAVA.pptx
U1 JAVA.pptxU1 JAVA.pptx
U1 JAVA.pptx
 
Introduction to object oriented programming
Introduction to object oriented programmingIntroduction to object oriented programming
Introduction to object oriented programming
 
ITT 202 PRINCIPLES OF OBJECT ORIENTED TECHNIQUE
ITT 202 PRINCIPLES OF OBJECT ORIENTED TECHNIQUEITT 202 PRINCIPLES OF OBJECT ORIENTED TECHNIQUE
ITT 202 PRINCIPLES OF OBJECT ORIENTED TECHNIQUE
 
Basic of Java
Basic of JavaBasic of Java
Basic of Java
 

Recently uploaded

VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
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
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
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
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...RajaP95
 
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...Call Girls in Nagpur High Profile
 

Recently uploaded (20)

VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
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
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
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
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
 
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...
 

Object Oriented Programming_combined.ppt.pdf

  • 1. Introduction to Object Oriented Programming Gayathri Namasivayam Introduction to OOP
  • 2. Topics ●Why use OOP? ●Building blocks of OOP ● Classes ● Objects ●What is OOP? ●OOP concepts ● Abstraction ● Encapsulation ● Inheritance ● Polymorphism ●Advantages vs Disadvantages ●Conclusion Introduction to OOP
  • 3. Topics ●Why use OOP? ●Building blocks of OOP ● Classes ● Objects ●What is OOP? ●OOP concepts ● Abstraction ● Encapsulation ● Inheritance ● Polymorphism ●Advantages vs Disadvantages ●Conclusion Introduction to OOP
  • 4. Why use OOP? ●Object Oriented Programming (OOP) is one of the most widely used programming paradigm ●Why is it extensively used? ● Well suited for building trivial and complex applications ● Allows re-use of code thereby increasing productivity ● New features can be easily built into the existing code ● Reduced production cost and maintenance cost ●Common programming languages used for OOP include C++, Java, and C# Introduction to OOP
  • 5. Topics ●Why use OOP? ●Building blocks of OOP ● Classes ● Objects ●What is OOP? ●OOP concepts ● Abstraction ● Encapsulation ● Inheritance ● Polymorphism ●Advantages vs Disadvantages ●Conclusion Introduction to OOP
  • 6. Building Blocks of OOP: Objects & Classes ●Object: models a ● Real world object (ex. computer, book, box) ● Concept (ex. meeting, interview) ● Process (ex. sorting a stack of papers or comparing two computers to measure their performance) ●Class: prototype or blueprint from which objects are created Introduction to OOP
  • 7. Building Blocks of OOP: Objects & Classes ●Class has ● Set of attributes or properties that describes every object ● Set of behavior or actions that every object can perform ●Object has ● Set of data (value for each of its attribute) ● Set of actions that it can perform ● An identity ●Every object belongs to a class Introduction to OOP
  • 8. Real World Example of Objects & Classes Object: FordCar1 Behavior Start, Accelerate, Reverse, Stop Attributes Color: Yellow Type: Coupe Model: Mustang Cylinder: 6 Attributes Color, Type, Model, Cylinder Behavior Start, Accelerate, Reverse, Stop Class: FordCar Behavior Start, Accelerate, Reverse, Stop Attributes Color: Orange Type: Coupe Model: Focus Cylinder: 4 Object: FordCar2 Introduction to OOP
  • 9. Another Real World Example.. Attributes Name, Height, Age Behavior Speak, Listen, Eat, Run, Walk Class: Person Object: Person1 Attributes Name: Ann Height: 5’ 4” Age: 21 Behavior Speak, Listen, Eat, Run, Walk Attributes Name: Adam Height: 5’ 9” Age: 24 Behavior Speak, Listen, Eat, Run, Walk Object: Person2 Introduction to OOP
  • 10. Class ●A class is a set of variables (to represent its attributes) and functions (to describe its behavior) that act on its variables Introduction to OOP
  • 11. Class ShippingBox int shipping_cost() { return cost_per_pound*weight; } sender_name : string receiver_name : string cost_per_pound : int weight : int shipping_cost() : int Introduction to OOP
  • 12. Object ●Object is an instance of a class that holds data (values) in its variables. Data can be accessed by its functions Introduction to OOP
  • 13. Objects of ShippingBox class sender_name = Jim receiver_name = John cost_per_pound = 5 weight = 10 shipping_cost() Object BoxB Object BoxA sender_name = Julie receiver_name = Jill cost_per_pound = 2 weight = 5 shipping_cost() Class ShippingBox Introduction to OOP
  • 14. Topics ●Why use OOP? ●Building blocks of OOP ● Classes ● Objects ●What is OOP? ●OOP concepts ● Abstraction ● Encapsulation ● Inheritance ● Polymorphism ●Advantages vs Disadvantages ●Conclusion Introduction to OOP
  • 15. What is OOP? ●Paradigm for problem solving by interaction among objects ●It follows a natural way of solving problems ● Ex. Ann wants to start her car (1) Ann walks to her car (2) Ann sends a message to the car to start by turning on the ignition (3)The car starts Introduction to OOP
  • 16. Problem Solving in OOP Problem: Ann wants to start her car Name = Ann Age = 21 Speak() Run() Walk() Object Ann Color = Yellow Type = Coupe Model = Mustang Cylinder = 6 Start() Accelerate() Stop() Object Ann’s car message Introduction to OOP
  • 17. Topics ●Why use OOP? ●Building blocks of OOP ● Classes ● Objects ●What is OOP? ●OOP concepts ● Abstraction ● Encapsulation ● Inheritance ● Polymorphism ●Advantages vs Disadvantages ●Conclusion Introduction to OOP
  • 18. Abstraction ●Extracting essential properties and behavior of an entity ●Class represents such an abstraction and is commonly referred to as an abstract data type Ex. In an application that computes the shipping cost of a box, we extract its properties: cost_per_pound, weight and its behavior: shipping_cost() Introduction to OOP
  • 19. Abstraction sender_name : string receiver_name : string cost_per_pound : int weight : int shipping_cost() : int Class Shipping Box Attributes Sender’s name, Receiver’s name, Cost of shipping per pound, Weight Behavior Calculate shipping cost Abstraction Introduction to OOP
  • 20. Topics ●Why use OOP? ●Building blocks of OOP ● Classes ● Objects ●What is OOP? ●OOP concepts ● Abstraction ● Encapsulation ● Inheritance ● Polymorphism ●Advantages vs Disadvantages ●Conclusion Introduction to OOP
  • 21. Encapsulation sender_name receiver_name cost_per_pound weight shipping_cost() ●Mechanism by which we combine data and the functions that manipulate the data into one unit ●Objects & Classes enforce encapsulation Introduction to OOP
  • 22. Topics ●Why use OOP? ●Building blocks of OOP ● Classes ● Objects ●What is OOP? ●OOP concepts ● Abstraction ● Encapsulation ● Inheritance ● Polymorphism ●Advantages vs Disadvantages ●Conclusion Introduction to OOP
  • 23. Inheritance ●Create new classes (derived classes) from existing classes (base classes) ●The derived class inherits the variables and functions of the base class and adds additional ones! ●Provides the ability to re-use existing code Introduction to OOP
  • 24. Inheritance Example BankAccount CheckingAccount SavingsAccount customer_name : string account_type : string balance : int insufficient_funds_fee : int deposit() : int withdrawal() : int process_deposit() : int customer_name : string account_type : string balance : int deposit() : int withdrawal() : int customer_name : string account_type : string balance : int interest_rate : int deposit() : int withdrawal() : int calculate_interest() : int Introduction to OOP
  • 25. Inheritance Example interest_rate : int calculate_interest() : int insufficient_funds_fee : int process_deposit() : int CheckingAccount SavingsAccount customer_name : string account_type : string balance : int deposit() : int withdrawal() : int BankAccount Introduction to OOP
  • 26. Topics ●Why use OOP? ●Building blocks of OOP ● Classes ● Objects ●What is OOP? ●OOP concepts ● Abstraction ● Encapsulation ● Inheritance ● Polymorphism* ●Advantages vs Disadvantages ●Conclusion (* To be covered in the next class) Introduction to OOP
  • 27. Disadvantages of OOP ●Initial extra effort needed in accurately modeling the classes and sub-classes for a problem ●Suited for modeling certain real world problems as opposed to some others Introduction to OOP
  • 28. Conclusion ●Classes & Objects ●Concepts in OOP ● Abstraction ● Encapsulation ● Inheritance ●Advantages & Disadvantages ●Next class ● Be prepared for an in-class activity (based on topics covered today)! ● Polymorphism in OOP! Introduction to OOP