OOP's Concept in Python
§ Object-Oriented
Programming is a methodology or paradigm to design a program using classes and
objects.
ü Object
ü Class
ü Inheritance
ü Polymorphism
ü Abstraction
ü Encapsulation
Object§ Objects are key to understanding object-oriented technology. Look around right now
and you will find many examples of real-world objects: your dog, your desk, your television set, your bicycle etc.
§ Object is a real-world entity.
Class
§ class is a logical model for creating an object.
§ class is a blue point of an object.
Encapsulation
§ Encapsulation:
In normal terms, Encapsulation is defined as wrapping up of data and
information under a single unit. In Object-Oriented Programming, Encapsulation
is defined as binding together the data and the functions that manipulate them.
§ Combining
of state and behavior in a single container is known as encapsulation. In
Python language encapsulation can be achieve using class keyword, state
represents declaration of variables on attributes and behavior represents
operations in terms of method.
Abstraction: -
§ Hiding
the internal implementation and highlighting the set of services that process
is called abstraction.
§ Another
way, it shows only important things to the user and hides the internal details
for example sending sms, you just type the text and send the message. You don’t
know the internal processing about the message delivery.
§ Abstraction
lets you focus on what the object does instead of how it does it.
Ex:-
a. Bank
ATM Screens (Hiding thee internal implementation and highlighting set of
services like withdraw, money transfer, mobile registration).
b. Mobile
phones (The mobile persons are hiding the internal circuit implementation and
highlighting touch screen).
c. Syllabus
copy (the institutions persons just highlighting the set of contents that
persons provided the persons are not highlighting the whole content).
Polymorphism
§ The
process of representing one Form in multiple forms is known as Polymorphism.
§ Polymorphism
is derived from 2 greek words: poly and morphs. The word "poly" means
many and "morphs" means forms. So polymorphism means many forms.
Real Time Polymorphism Example |
§ The
process of obtaining the data members and methods from one class to another
class is known as inheritance. It is one of the fundamental features of
object-oriented
programming.
What are the 4 Pillars of OOPs ?
Abstraction, Inheritance, Encapsulation and Polymorphism are the four pillars of OOPs.
v
Difference Between
Encapsulation and Abstraction in Java
Abstraction
means hiding the complex details and showing the only essential details which
is required to the end user whereas encapsulation means bind your data and code
together as a single unit.
Difference between Procedure Oriented and object oriented programming language?
Answer: -
Procedure Oriented
|
object oriented
|
|
Divided
into
|
In
POP program is divided
into
small parts called
functions.
|
In
OOP program is divided into parts called objects.
|
Importance
|
In
POP importance is not given to data but to function as well as sequence of
actions to be done.
|
In
OOP importance is given to the data rather than procedures or functions
because it works as a real world.
|
Approach
|
POP
follows TOP Down approach
|
OOP
follows Bottom UP approach
|
Access
Specifier
|
POP
does not have any access specifier.
|
OOP
has access specifier named public, private, protected etc.
|
Data
Moving
|
In
POP data can move freely from function to function in the system.
|
In
OOP object can move and communicate with each other through member functions.
|
Expansion
|
To
add new data and function in POP is not so easy
|
OOP
provides an easy way to add new data and function.
|
Post a Comment