3. Basic Concepts of Object Oriented Programming
- Objects
- Classes
- Data abstraction and encapsulation
- Inheritance
- Polymorphism
- Dynamic binding
- Message passing
3.1. Objects - a material thing that can be seen and touched.
Objects are smallest entity of a program. All you name is an object like table, chair or in programs user defined data , vectors, time and lists. When a program is executed, objects interact by sending messages to one another.
Any object can interact with any other object but they should be compatible to send message in type other object understand and similarly receive message
Example : Student and marks are two objects, in a program student object may send a message to inquire his/her marks in turn marks object will send message by sending marks detail.
3.2. Classes
Set or category of things, having some property or attribute.
Object contains data and code to manipulate data- so class is collection of objects of similar type.
3.3. Data abstraction and encapsulation
The wrapping up of data and function into a single unit (called class) is known as encapsulation.
Data is not accessible to the outside world, and only those functions which are wrapped in the class can access it. These functions provide the interface between the object’s data and the program.
This insulation of the data from direct access by the program is called data hiding or information hiding.
Abstraction refers to the act of representing essential features without including the background details or explanation.
Attributes are some time called data members because they hold information. The functions that operate on these data are sometimes called methods or member function.
3.4.
Inheritance
Inheritance is the process by which objects of one class acquired the properties of objects of another classes. It supports the concept of hierarchical classification.
In OOP, the concept of inheritance provides the idea of reusability. This means that we can add additional features to an existing class without modifying it.