0% found this document useful (0 votes)
12 views7 pages

T_2_KEY OR BASIC CONCEPT OF OOP

Object-oriented programming (OOP) is a programming paradigm that incorporates real-world concepts like classes, objects, encapsulation, polymorphism, inheritance, and abstraction to enhance software development and maintenance. Classes serve as blueprints for creating objects, which are instances of classes that encapsulate data and functions. Key benefits of OOP include code reusability, improved organization, and the ability to model complex systems effectively.

Uploaded by

joyalprincess
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views7 pages

T_2_KEY OR BASIC CONCEPT OF OOP

Object-oriented programming (OOP) is a programming paradigm that incorporates real-world concepts like classes, objects, encapsulation, polymorphism, inheritance, and abstraction to enhance software development and maintenance. Classes serve as blueprints for creating objects, which are instances of classes that encapsulate data and functions. Key benefits of OOP include code reusability, improved organization, and the ability to model complex systems effectively.

Uploaded by

joyalprincess
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

KEY OR BASIC CONCEPT OF OOP

• Object-oriented programming aims to implement real-world entities like


inheritance, hiding, polymorphism, etc. in programming
• The main aim of OOP is to bind together the data and the functions that operate on
them so that no other part of the code can access this data except that function.
• Object means a real word entity such as pen, chair, table etc.
• Object-Oriented Programming is a methodology or paradigm to design a program
using classes and objects.
• It simplifies the software development and maintenance by providing some concepts

Class

Object

CONCEPT
Encapsulation
OF
OOPS Polymorphism

Abstraction

Inheritence
CLASS
• A class is grouping of objects that have the identical properties, common behavior
and shared relationship.
• A class binds the data and its related functions together.
• A Class is a user-defined data type that has data members and member functions.
• Data members are the data variables and member functions are the functions used
to manipulate these variables together these data members and member functions
define the properties and behavior of the objects in a Class.
• The Entire group of data and code of an object can be built as a user-defined data
type using class.
• Objects are nothing but variable of type class.
• Once a class has been declared, the programmer can create a number of objects
associated with that class.
• A class is also called a model.
• Every object has its own value for each of its member variables.
OBJECT
• Objects are primary run-time entities in OOP.
• It is also instance of a class
• Every object has its own properties of features that illustrate what the object can
do.
• It can be singly recognized by its name.
• It declares the state that is shown by the data values of its characteristic at a specific
time. The state of the object varies according to the procedure used with it. It is
called as the action of the object.
• No memory is allocated but when an object is defined, memory is allocated.
• The action of the object depends up on the member function defined within its class.

Object : signup
Data :
First_Name_of_user
Last_name_of_user
Password
Confirm_password
Emai_id

Functions :
register
login

• The name of the object is signup. its data members are fist_name_of_user,
password , email_id.
• The various functions associated with the signup are register and login.

ENCAPSULATION
• The packing of data and functions into a single component is known as
encapsulation.
• It can be achieved by making the data members' scope private and the member
function’s scope public to access these data members.
• Encapsulation makes the data non-accessible to the outside world. The benefits of
encapsulation include.

o Data protection: Encapsulation hides the internal implementation details of


an object, protecting the data from unauthorized access or modification.
Ex: When we turn on the Bluetooth we can assess only the shared content of the
connected phone but not access to call or send message from that phone. That is hidden
from that unit and hence Encapsulation
o Code Organization: Encapsulation helps organize code by grouping related
data and functions together within a class. This improves code readability and
maintainability by providing a clear structure and reducing code clutter .
o Code Reusability: Encapsulation facilitates code reusability by encapsulating
functionality within objects. Objects can be easily reused in different parts of
the code or in different projects, promoting efficient development and
reducing redundant code.
Real world Example of Encapsulation
Automatic teller machines (ATMs)
• ATMs are a class that takes in data from the user, such as their PIN and money
amount, and displays options and icons. They also process the request.
Social networking websites
• Social networking websites, like Face book, make passwords private to keep
accounts safe.
Medical capsules
o Medical capsules combine multiple types of medicine into one capsule
Large organizations
o Organizations are made up of several departments, such as sales, production,
accounts, and purchase.
POLYMORPHISM
o Polymorphism makes it possible for the same function to act in a different way in
different classes.
o It holds an ability to take more than one form.
o Polymorphism accomplishes an important part in allowing object of different classes
to share the same external interface.

Example-1:
o A person at the same time can have different characteristics. A man at the same
time is a father, a husband, and an employee. So the same person possesses
different behavior in different situations. This is called polymorphism.

Example-2:
o In above example suppose we have to write a function to area() for all shapes ,
sometimes there are 2 properties, and sometimes there are 3 properties . We can
write the area () Method with the same name having different formulas; the
concerned method will be called according to parameters.
INHERITANCE
o Inheritance is the method by which objects of one class get the properties of objects
of another class.
o The class which inherits the features is known as the child class, and the class whose
features it inherited is called the parent class. The benefits of Inheritance include.
o Code Reusability: Inheritance allows classes to inherit properties and
behavior from a base class, promoting code reuse. Derived classes can extend
and specialize the functionality of the base class, eliminating the need to
rewrite common code.
o Polymorphism: Inheritance enables polymorphism, where objects of derived
classes can be treated as objects of their base class. This allows for more
flexible and dynamic programming, as different derived classes can be used
interchangeably through a common interface.
o Hierarchical Organization: Inheritance establishes a hierarchical relationship
among classes, reflecting real-world or conceptual hierarchies. This improves
code organization, understandability, and maintainability by representing
relationships and dependencies in a structured manner.

o In above example, Class Vehicle is the parent class, and Class Bus, Car, and Bike are child
classes and they are reusing the common feature (include wheels) this is called inheritance.
ABSTRACTION
o Abstraction means displaying only essential information and hiding the details.
o Data abstraction refers to providing only essential information about the data to the
outside world(private variables), hiding the background details or implementation.
o Abstraction is the idea of using a simple interface to access functionality without
needing to know the underlying details.
Here are some examples of abstraction in everyday life:
Driving a car
• You can drive a car without needing to know how the engine works. You only need
to know how to turn the key or press the start button. What all components your
car has. The car internal implementation and complex logic is completely hidden
from the user.

Making coffee
• You only need to know how to add water and coffee beans, turn on the coffee
maker, and select the type of coffee you want. You don't need to know how the
coffee maker works internally.

Using a mobile phone


• You can make calls, send messages, or browse the internet without needing to know
how these functions work.

Taking a picture with a Smartphone


• You can use the camera app to switch between front and rear-facing cameras, apply
filters, or blur the background. You don't need to see how the camera works.

Using an ATM
• You can perform functions like withdrawing cash, depositing cash, checking your
balance, or printing bills. You don't need to see how the ATM performs these
actions.
In programming, abstraction is used to hide complex details behind simple procedures. This
makes it easier for other developers to use the code.

ATM
MACHINE
• In above example we all use an ATM machine for cash withdrawal , cash deposit ,
money transfer , balance info , mini-statement,etc,. in our daily life.
• But we don’t know internally what things are happening inside ATM machine when
you insert an ATM card for performing any kind of operation.

You might also like