Object-oriented programming (OOP) is a computer programming model that organizes software design around data, or objects, rather than functions and logic.
An object can be defined as a data field that has unique attributes and behavior.
Classes are user-defined data types that act as the blueprint for individual objects, attributes and methods.
Objects are instances of a class created with specifically defined data. Objects can correspond to real-world objects or an abstract entity.
Methods are functions that are defined inside a class that describe the behaviors of an object.
Attributes are defined in the class template and represent the state of an object.
Encapsulation: containing information in an object, exposing only selected information
Inheritance: child classes inherit data and behaviors from parent class
Abstraction: only exposing high level public methods for accessing an object
Polymorphism: many methods can do the same task
Data Hiding: The user will have no idea about the inner implementation of the class. It will not be visible to the user how the class is storing values in the variables.
Increased Flexibility: We can make the variables of the class read-only or write-only depending on our requirement.
Reusability: Encapsulation also improves the re-usability and is easy to change with new requirements.
Testing code is easy: Encapsulated code is easy to test for unit testing.
Encapsulation is defined as the wrapping up of data under a single unit. It is the mechanism that binds together code and the data it manipulates.
Data abstraction is the process of hiding certain details and showing only essential information to the user.
Abstraction can be achieved with either abstract classes or interfaces
Abstract class
A class that is declared with an abstract keyword
Abstract method
A method that is declared without implementation
An abstract class may or may not have all abstract methods. Some of them can be concrete methods
Any class that contains one or more abstract methods must also be declared with an abstract keyword
There can be no object of an abstract class. That is, an abstract class can not be directly instantiated with the new operator
An abstract class can have parameterized constructors and the default constructor is always present in an abstract class
The word polymorphism means having many forms. In simple words, we can define polymorphism as the ability of a message to be displayed in more than one form
Runtime Polymorphism
It is also known as Dynamic Method Dispatch. It is a process in which a function call to the overridden method is resolved at Runtime.
Compile-time Polymorphism
It is also known as static polymorphism. This type of polymorphism is achieved by function overloading or operator overloading