Distinct features of Object oriented programming language

Q. What are the distinct features of Object oriented programming language?

 

                  OR

 

     What is object-oriented concept of programming? Discuss with the all features?

Ans. Object-oriented programming is a new method of resolving problems with computer. The fundamental features of the Object oriented programming language are the following:

Inheritance, Encapsulation, data abstraction, polymorphism, extensively, generality, persistence, message passing, delegation, multiple inheritances.

These important features supported by Object oriented programming language are described below:

Encapsulation: Encapsulation is the mechanism that binds together code and the data it manipulates and maintains both safe from exterior interference and mistreat. One way to think about encapsulation is as a protective wrapper that prevents the code and data from being randomly accessed by other code strictly controlled with a well defined interface. To connect this to the real world, consider the automatic transmission on an automobile. It encapsulates hundreds of bits of operation about your engine, like how much you are accelerating, the pitch of the surface you are on, and the position of the shift lever. You as user have simply one method of affecting this complex encapsulation by moving the gearshift lever. You can not affect the transmission by using the single turn or with shield wipers, for example. Therefore, the gearshift lever is a well defined (indeed, unique) interface to the transmission. Moreover, what takes place inside the transmission does not affect objects outside the transmission.    

Example:

Class A

{

Int a

Void fl ()

{

  -

}

};

Data abstraction: The technique of creating new user defined data type is called as Data abstraction. In C++, class is basic defined data type. In above example class A is user defined data type.

Inheritance: Inheritance is the process by which the one object acquires the properties of another object. This is significant because it assists the concept of classification. As mentioned previously, most knowledge is made manageable by hierarchical (that is, top down) classifications. For example, a golden retriever is part of the classification dog, which is turn is part of the mammal class, which is under the large class of animal. Without the use of hierarchical each objects would need to define all of its characteristics explicitly. However by use of inheritance, an objects needs only to define those qualities that make it unique within its class. It can take over its common attributes from its parent. Thus, it is the inheritance mechanism that makes it possible for one object to be a specific instance of a more general case.

Example:

    Class A

{

...............................

};

Class B : public : A

{

};

Here A is base class and class B is derived class. B can use all the public members of base class.

Polymorphism: Polymorphism (from the Greek, meaning "many forms") is a feature that allows one interface to be used for a general class of actions. The exact action is determined by the precise nature of the situation. Assume a stack (which is a last in, first out list). You might have a programme that requires three types of stacks. One stack is used for integer values, one stack is used for floating point values and one stack is used for characters. The algorithm that executes each stack is identical, even through the data being stored differs. In a non object oriented language, you would be requires three different sets of stack routines. With each sets using different names. However, due to polymorphism, in java you can state a general set of stack routines that all share the same names. More, usually, the concept of polymorphism is often expressed by the phrase "one interface", multiple methods." This means that it is possible to design a generic interface to a group of related activities. This helps in reducing complexity by reducing to allowing the interface to be used to specify a general class of action. It is the compiler's job to select the specific action (that is, method) as it applies to each situation.

Example:

Class A

{

Void fl (Int a)

{

-

}

Void fl (Int a, Int b)

{

-

}

};

Here function fl 0 is overloaded with one argument and two arguments

Message Passing: It is the process of invoking an operation on an object. In response to a message, the corresponding method (function) is executed in the objected. In previous e.g. function fl o can invoke any data type associated with it.

Extensibility: It is a feature, which allow the extension of the functionally of the existing software component. The example used in inheritance is achieving this feature.

Persistence: The phenomenon where the object outlives the program execution time and exists between executions of a program is known as persistence.

Delegation: It is alternative to inheritance. It is a way of making object composition as powerful as inheritance.

 Generality: It is a technique for defining software components that have more than one interpretation depending upon the data type of parameters. It can be achieved through function template. Example:

Template < class T >

Return type function name (arguments)

{

Body of template function

-

}

Multiple inheritances: C++ strongly supports the concept of reusability. The C++ classes can be reused in several ways. Once a class has been written and checked, it can be adapted by other programmes to suit their requirements. This is essentially done by developing new classes, reusing the properties of the existing ones. The process of developing a new class from an old one is called inheritance (or derivation). The old class is known as the base class and the new one is called the derived class or subclass. The derived class takes over some or all of the traits from the base class. A class can also take over properties from more than one class or from more than one level. A derived class with only one base class is called single inherited class and one with several base classes multiple inherited class. Consider following:

In case first, subclass C inherits classes A and B. However, in the hierarchy on the left, C inherit both A and B at the same time. In the one of on the right, B inherit A and C inherit B. By not allowing the inheritance of multiple base cases by a single subclass, Java greatly simplifies the inheritance model. Java provides an alternate approach known as interfaces to support the concept of multiple inheritances.

   Related Questions in Programming Languages

  • Q : What is Memory leak Memory leak : It is

    Memory leak: It is a situation in which memory which is no longer being employed has not been returned to the pool of free memory. The garbage collector is designed to return unreferenced objects to the free memory pool in order to shun memory leaks.<

  • Q : What is Left shift operator Left shift

    Left shift operator: Left shift operator (<<) is the bit manipulation operator. This moves the bits in its left operand zero or additional positions to the left, according to the value of its right operand. The zero bits are added up to the righ

  • Q : Use the Processing program for the

    1. Here is a short program. It prints out the value of a variable "x". Ernie and Bert disagree about what will be printed: Ernie says, the value gets changed in "changeX" so it will print "7", and Bert says, no, when the function exits the changes get reversed and the value goes back to "5". Expl

  • Q : Explain Mutator method Mutator method :

    Mutator method: It is a method specifically designed to permit controlled modification of a private attribute of a class. By convention, we name the mutators with a set prefix obeyed by the name of the attribute being transformed. For example, the mut

  • Q : Explain the term XForms Explain the

    Explain the term XForms.

  • Q : Computer science 1. Here is a short

    1. Here is a short program. It prints out the value of a variable "x". Ernie and Bert disagree about what will be printed: Ernie says, the value gets changed in "changeX" so it will print "7", and Bert says, no, when the function exits the changes get reversed and the value goes back to "5". Explain

  • Q : What do you mean by program counter

    What do you mean by the term program counter? Write down its use?

  • Q : Explain the relationship between XHTML

    Explain the relationship between XHTML and HTML?

  • Q : Explain the common uses of XML Explain

    Explain the common uses of XML.

  • Q : Define Parallel programming Parallel

    Parallel programming or parrelel computing is the concurrent use of multiple compute resources to resolve a specified problem. Parallel program always comprises of concurrently executing processes, problem decomposition relates to the manner in which

©TutorsGlobe All rights reserved 2022-2023.