You are on page 1of 19

Introduction to OOP

SEC4207

Introduction to OOP SEC4207 1


Lineup for today..
• Learning Outcomes
• Required Reading/Learning Materials
• Object
• Class
• OOP Concepts

Introduction to OOP SEC4207 2


Module
• Module Name : Introduction to OOP
• Module Code : SEC4207
• Credits : 20
• Learning Hours : 200
Teaching – 72
Student centered learning – 128

Teaching : Lecture and lab session


Assessment : 100% assessments
Introduction to OOP SEC4207 3
Learning Outcomes
• LO1: Understand the fundamentals of Object-Oriented Programming
concepts

Introduction to OOP SEC4207 4


Object oriented programming

Introduction to OOP SEC4207 5


What is an object ?
• Object is an entity that has state (properties) and behavior
(functions)
• For example a chair, pen, table, keyboard, bike, etc. It can be physical or
logical.
• An Object can be defined as an instance of a class.

Car Scale
Footballer

Complex Number
Introduction to OOP
$
Bank Account
SEC4207 Lion 6
What is an object?
• The “Car” Object

• In order to define the car object, we need to be able to abstract the states/attributes and
behaviors/functions of the car. We need to define the car in terms of :
• State What features/current state distinguish it from other objects?
• Behavior What it can do

Introduction to OOP SEC4207 7


What is an object ?
• The “Car” Object (cont’d)
• States/attributes
A car may have the following features or attributes :
• Color
• Speed
• Size
• Fuel
• Engine capacity
• Behavior
– Functionally, a car can do the following:
• Drive
• Stop/Brake
• Turn right
• Turn left

Introduction to OOP SEC4207 8


What is an object ?
• An object (a software object) is a software bundle of variables and related
methods.
• A software object maintains its state in variables and implements its behavior
with methods.
• State ==> variables
• Behavior ==> methods
• We can represent real-world objects using software objects.

Introduction to OOP SEC4207 9


What is a class?
• Collection of objects is called class.
• It is a logical entity.
• A class can also be defined as a blueprint from which you can create
an individual object.

Introduction to OOP SEC4207 10


Introduction to OOP SEC4207 11
Introduction to OOP SEC4207 12
Introduction to OOP SEC4207 13
OOP Concepts
•Abstraction
•Encapsulation
•Inheritance
•Polymorphism

Introduction to OOP SEC4207 14


Abstraction
• Abstraction is refer to the act of representing the essential features
without including the background details
• Hiding unnecessary data from the user and making the application as
user friendly is called an abstraction

Introduction to OOP SEC4207 15


Encapsulation
• Encapsulation leads to hiding the complexity of the implementation
inside the class.

Introduction to OOP SEC4207 16


Inheritance
• Inheritance is the sharing of attributes and operations among classes based on
a hierarchical relationship.
• Inheritance also facilitates reusability since all the attributes and behavior of
the main class is available to its sub-classes.

Introduction to OOP SEC4207 17


Class A Parent class/Super class/Base Class

Class B Class C

Child class/Sub class/Derived Class

Introduction to OOP SEC4207 18


Polymorphism
• Polymorphism is simply a name given to an action that is performed
by similar objects.

Introduction to OOP SEC4207 19

You might also like