OOPS
OOPS
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?
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)
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
Introduction to OOP
Real World Example of Objects &
Classes
Object: FordCar1
Attributes Behavior
Color: Yellow Start, Accelerate,
Reverse, Stop
Class: FordCar Type: Coupe
Model: Mustang
Attributes Cylinder: 6
Color, Type, Model, Cylinder
Behavior
Start, Accelerate, Reverse, Stop
Object: FordCar2
Attributes Behavior
Color: Orange Start, Accelerate,
Type: Coupe Reverse, Stop
Model: Focus
Cylinder: 4
Introduction to OOP
Another Real World Example..
Object: Person1
Behavior
Speak, Listen, Eat, Run, Walk Object: Person2
Attributes Behavior
Name:Chetan Speak,
Listen, Eat,
Height: 5’ 9”
Run, Walk
Age: 24
Introduction to OOP
Class
Introduction to OOP
Class ShippingBox
sender_name : string
receiver_name : string
cost_per_pound : int int shipping_cost() {
weight : int return cost_per_pound*weight;
}
shipping_cost() : int
Introduction to OOP
Object
Introduction to OOP
Objects of ShippingBox class
Object BoxA
sender_name = Julie
receiver_name = Jill
cost_per_pound = 2
weight = 5
shipping_cost()
Class
ShippingBox
Object BoxB
sender_name = Jim
receiver_name = John
cost_per_pound = 5
weight = 10
shipping_cost()
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?
Introduction to OOP
Problem Solving in OOP
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
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
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
Introduction to OOP
Inheritance Example
Introduction to OOP
Inheritance Example
BankAccount
customer_name : string
account_type : string
balance : int
deposit() : int
withdrawal() : int
CheckingAccount SavingsAccount
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
Disadvantages of OOP
Introduction to OOP
Conclusion
Introduction to OOP
INHERITANCE
● a) Inheritance allows a class to inherit properties and behaviors from multiple classes
simultaneously.
b) Inheritance in Java is denoted by the keyword extends.
●c) Private members of a superclass are accessible to subclasses.
d) Inheritance does not support code reuse and extensibility.
Introduction to OOP
INHERITANCE
● a) Inheritance allows a class to inherit properties and behaviors from multiple classes
simultaneously.
b) Inheritance in Java is denoted by the keyword extends.
●c) Private members of a superclass are accessible to subclasses.
d) Inheritance does not support code reuse and extensibility.
Introduction to OOP
ABSTRACTION
●Which statement about abstract classes in Java is correct?
Introduction to OOP
ABSTRACTION
●Which statement about abstract classes in Java is correct?
Introduction to OOP
POLYMORPHISM
Introduction to OOP
POLYMORPHISM
Introduction to OOP
INHERITANCE
Introduction to OOP
INHERITANCE
Introduction to OOP
POLYMORPHISM
● a) Static polymorphism
● b) Dynamic polymorphism
● c) Compile-time polymorphism
● d) Run-time polymorphism
Introduction to OOP
POLYMORPHISM
● a) Static polymorphism
● b) Dynamic polymorphism
● c) Compile-time polymorphism
● d) Run-time polymorphism
Introduction to OOP
INHERITANCE
Introduction to OOP
INHERITANCE
Introduction to OOP
Thank you!
Introduction to OOP