All object oriented programming languages provide mechanism that help you implement the object oriented model. It is therefore necessary to understand some of the concept extensively in object oriented programming.
Classes :-
The entire set of data and code of an object can be made using a user defined data type called as class.
It is one of the types of abstract data types.In sort, we can call the class is data type of object. Classes are user defined data types and they behave like the built in type of different programming languages.
Once class has defined , we can create any number of objects of that.
Class is the collection of similar type of objects.
Object :-
Object is called as the instance of the class.It is the run time entity in an object oriented system.In short, we can call object as a variable of type class.
After creation, objects take up space in computer memory and have associated address like 'record' in pascal and 'structure' in C.
When the program is executed, object can establish the path of communication among them by passing messages in between.
Each object is associated with data of type class with which they are created.A class is thus collection of objects of similar types.
For example, Maharashtra , Gujarat , Bengal , Goa , Tamilnadu , are the member of class India.
In object oriented programming language, objects are represented with data and methods(function) as shown in following figure.
Fig. a) Representation of an object
Fig. b) Example of representation of an object
See the above example, the class 'Batsman' has been declared.It contains data members Name and Innings as well as methods average ( ) and strike_rate ( ).
In order to create the object of type Batsman we have to use following notation.
Batsman opener;
Here 'opener' is name of the object.It will contain instance of class Batsman and the seprate copy of Name, Innings, average ( ) and strike_rate ( ).
If we want to give values to this object, following notation is to be used.
opener.Name = "Sachin"; opener.Innings = 310; etc.
and all calling methods,
opener.average ( ); opener.strike_rate ( );
Data Abstraction :-
The most striking feature of the class is 'Data encapsulation'. If refers to wrapping up of data and methods into the single unit.
The data contained in the object is not accessible out side of the class.The methods which are wrapped around the objects can access the data.
These methods provide interface between object's data and program. This insulation of the data from direct access by the program is called 'data hiding'.
In C++, the data hiding is implemented by writing private variable and functions.
Abstraction :-
Abstraction refers to the act of representing essential features without including the background details or explanation.
Classes use the concept of abstraction and are defined as a list of abstract attributes such as size , weight , cost and methods that operate on these attributes.
They encapsulation all essential properties of the objects that are to be created.
Sometimes, the attributes are called data members because they hold information.Since classes use the concept of data abstraction, they are known as 'Abstract Data Type'.
Inheritance :-
Inheritance is one of the most useful properties of object oriented programming.It is the process by which one class acquires the properties of objects of another class.It supports the concept of hierarchical classification.
If we take example of our family, son or daughter has properties of father or mother.
See the example given in above fig. 'Vehicles' is the main class we can call it a root class, base class or super class.It is having its own attributes and methods.
These properties are inherited to two different classes i.e Two-wheeler and four-wheeler. So, Two-wheeler and Four wheeler both have wheels and can be manually driven.
We can conclude that the process of inheritance provides the idea of re-usability.It is possible to add additional features to an existing class without modifying it.
Thus, new class can also be created which will have combined features of both classes.
In inheritance, each sub-class defines only those features that are unique to it. Without the use of classification, each class would have to explicity include all of its features.
Polymorphism :-
Polymorphism is the Greek term means that ability to take more the one form.Same ability is having in 'objects oriented programming' also.
One name can be used for different functions.But this function depends upon type of the data used in the actual operation.
Take an example of one method called area ( ). When we pass one argument to this method, it will consider it as side of a square and according to that area of the square will be calculated. When we pass two arguments to area ( ) , it will consider them as length and breath of a rectangle and calculate area accordingly.And after passing three argument to area ( ), these can be three sides of the triangle to calculate the area of it. So, here method area ( ) is having property of polymorphism i.e ability to take more than one forms.
Our method name is same but its data i.e parameters decides which function to be get executed.
More generally, the concept of polymorphism is often expressed by the phrase "one interface, multiple method."
Polymorphism plays an important role in objects having different internal structure to share their same external interface.
In cpp polymorphism is implement by function overloading and operator overloading. In operator overloading when '+' operator is applied on two whole number then we get addition for it and when we operate it on two strings then we get concatenated string.
Dynamic Binding :-
The term binding refers to assigning one thing to another.In programming languages, there are two types of binding i.e static and dynamic.
Static binding means at the time of compilation and execution, compiler knows what to do and with which values?
But, in case of dynamic building compiler decides the function at run time i.e at execution time. Thus, at the time of compilation , compiler does not know which method to call? This decision is made after execution of program.
In C++ programming language, this concept is applied with 'virtual function'. This is also called as run time polymorphism.
Message Communication :-
An object oriented program consists of a set of objects that communicate with each other.This process of programming in an object oriented language involves following basic operation.
Creating classes that define objects and their behavior.
Creating objects from class definitions.
c. Establishing communication among objects.
Fig. communication among the objects
Object communicate with each other by sending and receiving information much the same way as people pass message to one another as in figure.
The object may contain the method to pass message from one object to another.This method is used along with name of the object.
Classes :-
The entire set of data and code of an object can be made using a user defined data type called as class.
It is one of the types of abstract data types.In sort, we can call the class is data type of object. Classes are user defined data types and they behave like the built in type of different programming languages.
Once class has defined , we can create any number of objects of that.
Class is the collection of similar type of objects.
Object :-
Object is called as the instance of the class.It is the run time entity in an object oriented system.In short, we can call object as a variable of type class.
After creation, objects take up space in computer memory and have associated address like 'record' in pascal and 'structure' in C.
When the program is executed, object can establish the path of communication among them by passing messages in between.
Each object is associated with data of type class with which they are created.A class is thus collection of objects of similar types.
For example, Maharashtra , Gujarat , Bengal , Goa , Tamilnadu , are the member of class India.
In object oriented programming language, objects are represented with data and methods(function) as shown in following figure.
Fig. a) Representation of an object
Fig. b) Example of representation of an object
See the above example, the class 'Batsman' has been declared.It contains data members Name and Innings as well as methods average ( ) and strike_rate ( ).
In order to create the object of type Batsman we have to use following notation.
Batsman opener;
Here 'opener' is name of the object.It will contain instance of class Batsman and the seprate copy of Name, Innings, average ( ) and strike_rate ( ).
If we want to give values to this object, following notation is to be used.
opener.Name = "Sachin"; opener.Innings = 310; etc.
and all calling methods,
opener.average ( ); opener.strike_rate ( );
Data Abstraction :-
The most striking feature of the class is 'Data encapsulation'. If refers to wrapping up of data and methods into the single unit.
The data contained in the object is not accessible out side of the class.The methods which are wrapped around the objects can access the data.
These methods provide interface between object's data and program. This insulation of the data from direct access by the program is called 'data hiding'.
In C++, the data hiding is implemented by writing private variable and functions.
Abstraction :-
Abstraction refers to the act of representing essential features without including the background details or explanation.
Classes use the concept of abstraction and are defined as a list of abstract attributes such as size , weight , cost and methods that operate on these attributes.
They encapsulation all essential properties of the objects that are to be created.
Sometimes, the attributes are called data members because they hold information.Since classes use the concept of data abstraction, they are known as 'Abstract Data Type'.
Inheritance :-
Inheritance is one of the most useful properties of object oriented programming.It is the process by which one class acquires the properties of objects of another class.It supports the concept of hierarchical classification.
If we take example of our family, son or daughter has properties of father or mother.
See the example given in above fig. 'Vehicles' is the main class we can call it a root class, base class or super class.It is having its own attributes and methods.
These properties are inherited to two different classes i.e Two-wheeler and four-wheeler. So, Two-wheeler and Four wheeler both have wheels and can be manually driven.
We can conclude that the process of inheritance provides the idea of re-usability.It is possible to add additional features to an existing class without modifying it.
Thus, new class can also be created which will have combined features of both classes.
In inheritance, each sub-class defines only those features that are unique to it. Without the use of classification, each class would have to explicity include all of its features.
Polymorphism :-
Polymorphism is the Greek term means that ability to take more the one form.Same ability is having in 'objects oriented programming' also.
One name can be used for different functions.But this function depends upon type of the data used in the actual operation.
Take an example of one method called area ( ). When we pass one argument to this method, it will consider it as side of a square and according to that area of the square will be calculated. When we pass two arguments to area ( ) , it will consider them as length and breath of a rectangle and calculate area accordingly.And after passing three argument to area ( ), these can be three sides of the triangle to calculate the area of it. So, here method area ( ) is having property of polymorphism i.e ability to take more than one forms.
Our method name is same but its data i.e parameters decides which function to be get executed.
More generally, the concept of polymorphism is often expressed by the phrase "one interface, multiple method."
Polymorphism plays an important role in objects having different internal structure to share their same external interface.
In cpp polymorphism is implement by function overloading and operator overloading. In operator overloading when '+' operator is applied on two whole number then we get addition for it and when we operate it on two strings then we get concatenated string.
Dynamic Binding :-
The term binding refers to assigning one thing to another.In programming languages, there are two types of binding i.e static and dynamic.
Static binding means at the time of compilation and execution, compiler knows what to do and with which values?
But, in case of dynamic building compiler decides the function at run time i.e at execution time. Thus, at the time of compilation , compiler does not know which method to call? This decision is made after execution of program.
In C++ programming language, this concept is applied with 'virtual function'. This is also called as run time polymorphism.
Message Communication :-
An object oriented program consists of a set of objects that communicate with each other.This process of programming in an object oriented language involves following basic operation.
Creating classes that define objects and their behavior.
Creating objects from class definitions.
c. Establishing communication among objects.
Fig. communication among the objects
Object communicate with each other by sending and receiving information much the same way as people pass message to one another as in figure.
The object may contain the method to pass message from one object to another.This method is used along with name of the object.
0 Comments:
Post a Comment