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

Comp. Oops Notes....

Uploaded by

ad599066
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)
21 views

Comp. Oops Notes....

Uploaded by

ad599066
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/ 6

OBJECT – ORIENTED PROGRAMMING

• Object=Data +Methods
• Problem is divided into Objects ( data structure with data
fields, methods and their interaction) rather than Functions
• 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. Organization of data and function in OOPS.

Some striking features of the Object Oriented programming are :-


1. Emphasis is on doing rather than procedure.
2. programs are divided into what are known as objects.
3. Data structures are designed such that they characterize the objects.
4. Functions that operate on the data of an object are tied together in the data structure.
5. Data is hidden and can’t be accessed by external functions.
6. Objects may communicate with each other through functions.
7. New data and functions can be easily added.
8. Follows bottom-up approach in program design.

Basic Concept of OOPS : 1.OBJECTS:


1. Objects  An object is a logical entity containing data and code that manipulates that
2. Classes data.
These four are
3. Data abstraction and encapsulation  It is an instance of a class.
principle of 4. Inheritance  It is a run-time entity.
oops 5. Polymorphism  Objects may be :-
6. Dynamic binding A) logical objects like a library software.
7. Message passing B) physical objects like a person, a chair, a table etc.
 The state of an object changes according to the methods applied to it.
 Objects communicate with other objects through functions.
 An object is a variable only that represents data as well as functions
2.CLASSES: required for operating data

 A class is an entity that specifies what data and functions will be included in object of this class.
 Collection of an object that has the common attributes and methods.
 A blueprint for creating objects.
 A blueprint for creating objects.
 E.g. objects representing different types of employees in an organization may be represented by a class employee.
 It’s objects may be declared as employee obj1, obj2, obj3;
 Where employee is the class name and obj1, obj2, obj3 are the objects of class employee
3. Data abstraction and encapsulation :
Data Encapsulation : The wrapping up of data and functions into a single unit (called class) is known as encapsulation. Data
encapsulation is the most striking feature of a class. The data is not accessible to the outside world, and only those functions
which are wrapped in the class can access it. These functions provide the interface between the object’s data and the program.
This insulation of the data from direct access by the program is called data hiding or information hiding.
Data Abstraction : Abstraction refers to the act of representing essential features without including the background details or
explanations. Classes use the concept of abstraction and are defined as a list of abstract attributes such as size, weight and cost,
and functions to operate on these attributes.
Advantage of Data Abstraction : 1)Avoid code duplication and increase reusability.
2)Can change internal implementation of class independently.
Consider a real-life example of a man driving a car. The man only knows that pressing the accelerators will increase
the speed of the car or applying brakes will stop the car, but he does not know about how on pressing the accelerator
the speed is increasing, he does not know about the inner mechanism of the car or the implementation of the
accelerator, brakes, etc in the car. This is what abstraction is.
Consider a real-life example of encapsulation, in a company, there are different sections like the accounts section,
finance section, sales section, etc. The finance section handles all the financial transactions and keeps records of all
the data related to finance. Similarly, the sales section handles all the sales-related activities and keeps records of all
the sales. Now there may arise a situation when for some reason an official from the finance section needs all the
data about sales in a particular month. In this case, he is not allowed to directly access the data of the sales section.
He will first have to contact some other officer in the sales section and then request him to give the particular data.
This is what encapsulation is. Here the data of the sales section and the employees that can manipulate them are
wrapped under a single name “sales section”.

4. Inheritance : Inheritance is the process in which the object of one class acquire the properties of objects of another
class. When we write a class, we inherit properties from other classes. So when we create a class, we do not need to
write all the properties and functions again and again, as these can be inherited from another class that possesses it.
Inheritance allows the user to reuse the code whenever possible and reduce its redundancy.

5. Polymorphism: The word polymorphism means having many forms. In simple words, we can define
polymorphism as the ability of a message to be displayed in more than one form. For exam ple, A person at
the same time can have different characteristics. Like a man at the same time is a father, a husband, an
employee. So the same person posses different behavior in different situations. This is called
polymorphism.
6. Dynamic Binding: In dynamic binding, the code to be executed in response to the function call is
decided at runtime. Dynamic binding means that the code associated with a given procedure call is not
known until the time of the call at run time. Dynamic Method Binding One of the main advantages of
inheritance is that some derived class D has all the members of its base class B. Once D is not hiding any
of the public members of B, then an object of D can represent B in any context where a B could be used.
This feature is known as subtype polymorphism.
7. Message Passing: It is a form of communication used in object-oriented programming as well as parallel
programming. Objects communicate with one another by sending and receiving information to each other. A
message for an object is a request for execution of a procedure and therefore will invoke a function in the
receiving object that generates the desired results. Message passing involves specifying the name of the
object, the name of the function, and the information to be sent.
Features of OOPs :- Either write this definition or above definition
1. Reusability of the code—use of inbuilt libraries/ functions.
or detail explanation as done above
2. Encapsulation- wrapping up of data and functions into a single unit.
3. Abstraction- a paradigm that concentrates on the essential parts of the problem and excludes finer details.
problem and excludes finer details.
4. Polymorphism-poly=many; morphs=forms of a function.
5. Data Hiding- some part of data may be public, some private and some may be protected.
6. Inheritance-The process of creating new classes (derived classes/ subclasses/ child classes)from the existing
classes (base classes/ super classes/ parent classes). The child classes inherits the properties of its parent classes.

Benefits of OOPS :-
1. Through inheritance we can eliminate redundant code and extend the use of existing classes.
2. We can build programs from the standard working modules that communicate with one another,
rather than having to start writing the code from scratch. This leads to saving of development time and
higher productivity.
3. This principle of data hiding helps the programmer to build secure programs that can’t be invaded by
code in other parts of the program.
4. It is possible to have multiple instances of an object to co-exist with out any interference.
5. It is easy to partition the work in a project based on objects.
6. Object-oriented systems can be easily upgraded from small to large systems.
7. Message passing techniques for communication between objects makes the interface description
with external systems much simpler.
8. Software complexity can be easily managed.
9. Abstraction makes it possible to change the data structure of an object, without affecting the
operation of the program.
10. Increased programming productivity.
Here, is a characteristics of oops with example. If ques. Is what are the characteristics of oops.write def
and example. Either write below example or above example.

You might also like