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 : Explain Twos-complement notation

    Twos-complement notation: In twos-complement notation, the most noteworthy bit in an integer value is employed as the sign bit. A 1 bit points out a negative number, and a 0 bit points out a positive number. The positive number can be transformed to i

  • Q : Describe Data type Data type : It is a

    Data type: It is a specifier to build memory block of some particular size and kind. C++ provides two kinds of data types: A) Fundamental type: That is not composed

  • Q : C-C++ interfaces into WLS JMS Normal 0

    Normal 0 false false

  • Q : What is an Implicit type conversion

    Implicit type conversion: The type conversion which does not need a cast. Implicit type conversions usually do not comprise any loss of information. For example, joining an integer operand with a floating point operand in an arithmetic expression will

  • Q : What is Bounded repetition Bounded

    Bounded repetition: The Repetition where statements within a loop's body are executed a fixed number of times and the number of times is established whenever the loop began. There is no control structure in Java which guarantees the bounded repetition

  • Q : Define Main method Main method : It is

    Main method: It is the beginning point for program execution public static void main(String[] args)

  • Q : Define the term Field Define the term

    Define the term Field: Variables stated within a class or interface, exterior of the methods. The fields are members of a class.

  • Q : Automaton distributed in the class

    Write a code in a c++/java  for the automaton distributed in the class which accepts keywords(cat,bat,cab). Create an input file with these words may be two or three copies of these words scattered in a paragraph and show that your program does accept these words and gives an output to that

  • Q : What is Primitive Type Casting

    Primitive Type Casting: C/C++ allows you to cast between totally unrelated types. This can be problematic for model checking. Avoid type casting between unrelated types and in particular primitive types. For example,

    Q : What are ORB-IOR-a servant-a POA manager

    In CORBA, what are i) an ORB ii) an IOR iii) a servant iv) a POA and v) a POA manager?

©TutorsGlobe All rights reserved 2022-2023.