Guest

What is Object Oriented Programming

What is Object Oriented Programming

Grade:Upto college level

3 Answers

Aditi Chauhan
askIITians Faculty 396 Points
15 years ago

A type of programming in which programmers define not only the data type of a data structure, but also the types of operations (functions) that can be applied to the data structure. In this way, the data structure becomes an object that includes both data and functions. In addition, programmers can create relationships between one object and another. For example, objects can inherit characteristics from other objects.

* One of the principal advantages of object-oriented programming techniques over procedural programming techniques is that they enable programmers to create modules that do not need to be changed when a new type of object is added. A programmer can simply create a new object that inherits many of its features from existing objects. This makes object-oriented programs easier to modify.

Object-oriented programming (OOP) is a programming paradigm that uses "objects" and their interactions to design applications and computer programs.

 Programming techniques may include features such as information hiding, data abstraction, encapsulation, modularity, polymorphism, and inheritance. It was not commonly used in mainstream software application development . Many modern programming languages now support OOP.

Swati Kharodia
23 Points
15 years ago

The Main Feature of Object Oriented Programming are :

Encapsulation:

The term encapsulation is often used interchangeably with information hiding.Information hiding in computer science is the principle of hiding of design decisions in a computer program that are most likely to change, thus protecting other parts of the program from change if the design decision is changed.In modern programming languages, the principle of information hiding manifests itself in a number of ways, including encapsulation (given the separation of concerns) and polymorphism.A common use of information hiding is to hide the physical storage layout for data so that if it is changed, the change is restricted to a small subset of the total program.

Polymorphism 

In general, polymorphism describes multiple possible states for a single property.In Short Single Interface Multiple Behaviour.

polymorphism is a programming language feature that allows values of different data types to be handled using a uniform interface. The concept of parametric polymorphism applies to both data types and functions. A function that can evaluate to or be applied to values of different types is known as a polymorphic function. A data type that can appear to be of a generalized type is designated polymorphic data type like the generalized type from which such specializations are made.

Inheritance

In object-oriented programming, inheritance is a way to form new classes (instances of which are called objects) using classes that have already been defined.The new classes, known as derived classes, take over (or inherit) attributes and behavior of the pre-existing classes, which are referred to as base classes (or ancestor classes). It is intended to help reuse existing code with little or no modification.

Abstraction

Complexity is removed using Abstraction.

 

Ravi Sharma
29 Points
15 years ago

Features of Object-Oriented Programming Languages

Data encapsulation or data abstraction

Data encapsulation, sometimes referred to as data hiding, is the mechanism whereby the implementation details of a class are kept hidden from the user. The user can only perform a restricted set of operations on the hidden members of the class by executing special functions commonly called methods. The actions performed by the methods are determined by the designer of the class, who must be careful not to make the methods either overly flexible or too restrictive. This idea of hiding the details away from the user and providing a restricted, clearly defined interface is the underlying theme behind the concept of an abstract data type.

Inheritance or derivation

Inheritance, or derivation, provides a clean mechanism whereby common classes can share their common features, rather than having to rewrite them. For example, consider a graph class which is represented by edges and vertices and some (abstract) method of traversal. Next, consider a tree class which is a special form of a graph. We can simply derive tree from graph and the tree class automatically inherits the concept of edges, vertices and traversal from the graph class. We can then restrict how edges and vertices are connected within the tree class so that it represents the true nature of a tree.

 

Dynamic or runtime binding

 Quite often when using inheritance, one will discover that a series of classes share a common behaviour, but how that behaviour is implemented is different from class to class. Such a situation is a prime candidate for the use of dynamic or runtime binding which is also referred to as polymorphism.

Going back to our previous example, we may decide to derive two tree classes from our graph class, the first class, in_order_tree would be traversed in an ``in order'' fashion when it received a traverse() message, whereas post_order_tree would be traversed in a ``post order'' manner. The different traversal algorithms could be incorporated into a dynamically bound traverse() method. Now, when one of these trees is passed to a function which accepts a reference to a graph class, the invocation of the traverse() method via the graph parameter would call the correct traversal algorithm at runtime depending upon which tree was passed to the function. This reduces the burden on the programmer since a tag does not have to be associated with each class derived from graph to distinguish it from other graphs. In addition, the programmer would not have to maintain an unwieldy switch statement to determine which traversal algorithm to invoke since this is all handled automatically by the compiler.

Think You Can Provide A Better Answer ?

ASK QUESTION

Get your questions answered by the expert for free