Object oriented programming is known as OOPs.
OOP is a method of implementation in which programs
are organized as co-operative collections of objects, each of which represents
an instance of some class and whose classes are all members of a hierarchy of
classes united through the property called inheritance.
Three important concepts about OOP are objects,
classes and inheritance.
Structured Programming views
the two core elements -Data & Functions as two separate entities. Object oriented programming views them as a
single entity. OOP is a new way of solving problems with computers. OOP languages provide the programmer the ability
to create class hierarchies, instantiate co-operative objects collectively
working on a problem to produce the solution and send messages between objects
to process themselves.
The fundamental features of the OOPs are the
following:
§ Encapsulation
§ Data Abstraction
§ Inheritance
§ Polymorphism
§ Message Passing
Encapsulation: A mechanism that associates the code and the data
it manipulates into a single unit and keeps them safe from external
interference and misuse.
Data Abstraction: The technique of creating new data types that is
well suited to an application to be programmed. It provides the ability to
create user-defined data types, for modeling a real world object, having the
properties of built in data types and a set of permitted operators.
Inheritance: It allows the extension and reuse of existing
code without having to rewrite the code from scratch. Inheritance involves the
creation of new classes (derived classes) from the existing ones (base classes),
thus enabling the creation of a hierarchy of classes that stimulate the class
and subclass concept of the real world. The new derived class inherits the
members of the base class and also adds its own.
Polymorphism: It allows a single name/operator to be associated
with different operations depending on the type of data passed to it. In C++ it
is achieved by function over loading,operator over loading and dynamic
binding(virtual functions).
Message Passing: The process
of invoking an operation on an object. In response to a message, the
corresponding method (function) is executed in the object.
OBJECTS
An
object can be a person, a place or a thing with which the computer must deal.
Some objects may correspond to real-world entities such as students, employees,
bank accounts inventory items etc. Every
object will have data structures called attributes and behaviour called
operations.
Consider
the object having the attributes: Account
Number, Account type, Name, Balance and Operations: Deposit, Withdraw, Enquire.
CLASSES
The
objects with the same data structure(attributes) and behavior (operations) are
grouped into a class. All those objects possessing
similar properties are grouped into the same unit.
Every object is associated with data
and functions which define meaningful operations on that object.
No comments:
Post a Comment