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 : Persistent and non-persistent objects

    Illustrate the difference between persistent and non-persistent objects in the programming?

  • Q : Define the term Protected statement

    Define the term Protected statement: It is a statement within the try clause of the try statement.

  • Q : Program and process Explain the term

    Explain the term program and process?

  • Q : Define Class scope Class scope :

    Class scope: Private variables stated outside the methods in a class contain class scope. They are available from all methods within a class, in spite of the order in which they are stated. The private methods too contain class scope. Variables and me

  • Q : Types of buffering supported by UNIX

    Explain different types of buffering which is supported by the UNIX?

  • Q : Assembly condition codes What do you

    What do you mean by the term assembly condition codes?

  • Q : Explain Method overloading Method

    Method overloading: Two or more techniques with similar name stated within a class are said to be overloaded. This exerts to both constructors and other methods. The overloading applies via a class hierarchy, thus a sub class may overload a method sta

  • Q : What is Control structure Control

    Control structure: A statement which affects the flow of control in a method. The typical control structures are if statements and loops.

  • Q : Describe Overriding for restriction

    Overriding for restriction: It is a form of method overriding in which the sub-class version of a method calls the super-class version first of all and then employs or manipulates the outcome or consequences of that call in some manner.

  • Q : Define Case sensitive Case sensitive :

    Case sensitive: The test which is sensitive to whether a character is in upper-case (example, 'A') or lower-case (example, 'a').

©TutorsGlobe All rights reserved 2022-2023.