Class in Object-oriented Programming
In object-oriented programming, a class is a blueprint for creating objects. It is a logical entity that contains some attributes and methods. It is only a logical component and not a physical entity.
For example, If you had a class called “Car” it could have objects like Mercedes, BMW, Toyota, etc. Its properties (data members) can be the price or speed of these cars. While the methods of these cars are driving, reverse, and braking.
In object-oriented programming, the object is an instance of a class. The object is an entity that has a state and behavior. It may be any real-world object like a mouse, keyboard, chair, table, pen, etc.
For example, The Car class can have multiple instances (objects) and each object may have a different attribute value.
Inheritance in Object-oriented Programming
It is a mechanism in which one class acquires the property of another class. Inheritance is the procedure in which one class inherits the attributes and methods of another class.
Types of Inheritance
- Single Inheritance – One derived class inherits from one super class.
- Multilevel Inheritance – One derived class inherits from other derived classes.
- Multiple Inheritance One derived class inherits from many super classes.
- Hierarchal Inheritance – More than one derived classes inherit from one super class.
Polymorphism contains two words, ‘poly’ means ‘many’ and ‘morph’ points at ‘forms’. Thus, polymorphism as a whole would mean ‘a property of having many forms’.
In other words, it means one method with multiple implementations, for a certain class of action.
For example, The + Operator has the primary purpose of adding two numbers. However, it can also concatenate numeric operands with string operands
It is the mechanism that binds together code and the data it manipulates. It is a process of wrapping up data into a single unit.
Abstraction is the concept of object-oriented programming that “shows” only essential attributes and “hides” unnecessary information. It’s used to create a boundary between the application and the client programs.
For example, You can turn on and off, change the channel, adjust the volume in a TV using the remote, BUT you do not know how it receives signals over the air or through a cable, how it translates them and finally displays them on the screen.
- Top 10 Programming Languages to Learn in 2022
- Top Python Interview Questions Recruiters are fond of in 2022