0% found this document useful (0 votes)
39 views

Object Oriented Programming: By: Irfan U. Memon

This document provides an overview of object-oriented programming (OOP). It defines key OOP concepts like classes, objects, attributes, and methods. It explains that classes are blueprints that describe objects, and objects are instances of classes. The document also outlines the four main principles of OOP: abstraction, encapsulation, inheritance, and polymorphism. It provides examples of real-world objects like computers and how they relate to classes and objects in programming.

Uploaded by

Irfan Memon
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views

Object Oriented Programming: By: Irfan U. Memon

This document provides an overview of object-oriented programming (OOP). It defines key OOP concepts like classes, objects, attributes, and methods. It explains that classes are blueprints that describe objects, and objects are instances of classes. The document also outlines the four main principles of OOP: abstraction, encapsulation, inheritance, and polymorphism. It provides examples of real-world objects like computers and how they relate to classes and objects in programming.

Uploaded by

Irfan Memon
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 24

Object Oriented Programming

BY: IRFAN U. MEMON


B.E (SOFTWARE ENGINEERING)
MEHRAN UET. JAMSHORO
Prerequisites

• Foundations of Programming
Programming Fundamentals
Outlines

• Programming Paradigms
• Object Oriented Programming
(OOP)?
• Need of OOP
• Classes
• Objects
• How to create Objects
Programming Paradigms

• A programming paradigm is a fundamental style of


computer programming, a way of building the structure
and elements of computer programs.
• Two Programming Paradigms
• Structural Programming
• Object Oriented Programming.
Data
Logic
Data
Logic

Data
Logic
What Object Orientation is ?
• Programming Paradigm
• Not a programming Language.
• Set of Ideas that is supported by many
programming languages.
e.g C++, Java, C#, Php, Objective-C (Many others)
Object Oriented Programming Languages.
Object Oriented Programming (OOP)
What is An Object?
What are object in real world?
• Things
• Is this desk?
• This Computer?
• A Pen?

They are all objects, these are all things.


• Objects are separate from one another
They have their own existence
• Objects have Attribute
A computer can be on or off
A pen can be blue or blue
• These are the attributes of any object
Things like color, weight, and size
They describe the current state of an Object
• State of on object is independent of other
We turn on PC on, it does not turn all PCs
Objects in Computer

• Objects are instances of Class.


• Things that have Identity, Attribute &
behavior.
• An object is basically a block of memory that
has been allocated and configured according to
the blueprint
Objects in Computer
• An object is anything that can be modelled as
data (properties) and operations on that data
(methods).
• In real world Objects are tangible
things
• Where as in computers objects
can be intangible things also

Balance: Rs: 15000 Name: Ali Name: Saba


Number: 36-5 Gender: Male Gender: Female
Deposite() walk() walk()
Withdraw() talk() talk()

Bank Account Object Person Object Person Object


What is a Class?
Class
• Classes are templates or blueprints which
are followed to create an Object.
• A detailed description or definition.
• A is not an object it self.
What does a class Describe

Attributes Behavior
name Walk
Height Run
Weight Jump
Gender Speak
age sleep
What does a class Describe

Properties Methods
name Walk
Height Run
Weight Jump
Gender Speak
age sleep
Object Oriented Paradigm
• Abstraction
• Polymorphism
• Inheritance
• Encapsulation
Abstraction
• Focus on the essentials
• Ignore the Irrelevant
• Ignore the unimportant
• Not the separate class, one generalized
class
• Focuses on how our class would look
like rather than what is our class
Encapsulation
• Idea of surrounding something
• Bundling the attributes and behavior in
the same class.
• Also want restrict access in or out of
the class. (Data Hiding)
• Black Boxing.
• Why Hiding?
Inheritance
• Creating a class based on another class
• Code Re-use
• Base Class is know as Super class
• New formed class as Child Class
Polymorphism
• Poly “Many”, morph “shapes”
• It enables us automatically do the
correct behavior even if what we are
working with can take many forms.
• (+) sign
Methods
• method is a code block that contains a series of statements

• Every Java program has at least one class with a method


main method

To Use method we need two things


• Defining a Method
• Calling a Method
Defining Methods in Java
The syntax for defining a method in Java is as follows

<Access Specifier> <Return Type> <Method Name> (Parameter


List)
{
Method Body
}
Types of Methods
Procedure
• A method is known as procedure if it does not return any value
OR
• If it’s return type is void
Function
• A method is known as function if it do returns any value
OR
• If it’s return type is not void

You might also like