Object Oriented Programming (OOP) is a programming paradigm that uses classes and objects to organise code. Every developer has used at some point in their career. It is taught as the standard way to code in most computer courses across India.
It simplifies software development and maintenance by providing some concepts:
Let's dive into each of these in a little more details.
An object is any entity that has a state and behavior. For example, a chair, pen, table, keyboard, bicycle, etc. It could be physical or logical in nature. An instance of a class can be defined as an Object. An object contains an address and occupies some memory space.
The only thing important is the type of message that is accepted and the type of response that the objects provide.
The term "class" refers to a collection of objects. It's a logical entity. A class can alternatively be defined as a blueprint from which an individual object can be created. Class doesn't use much space.
Inheritance occurs when one object inherits all of the characteristics and behaviors of a parent object. It allows code reusability. It's used to achieve polymorphism at runtime.
Polymorphism occurs when a single task is performed in multiple ways. For example, to convince a consumer in a different way, to draw something, like a triangle, rectangle, etc.
To create polymorphism in Java, we use method overloading and method overriding.
Abstraction is the process of hiding internal features while displaying functionality. For example, we don't know the internal processes of a phone call.
To achieve abstraction in Java, we use abstract class and interface.
Encapsulation is the process of binding (or wrapping) code and data into a single unit. For example, a capsule is wrapped in various medicines.
A java class is an example of encapsulation.
That's all for now. Until next time.