Object-oriented programming in Java.(Introduction)

In software programming, we have various types of programming languages. Major languages amongst them are either procedural or object-oriented in nature.

In procedural programming languages, bigger problems are broken down into small solvable problems. These small problems are converted into procedures or functions. This way the procedural programming language emphasizes functions rather than data. Thus procedural languages neglected data completely and thus they do not ensure data security at all.

This problem was taken care of by object-oriented programming language. Object-oriented programming is a way of designing and programming software by manipulating objects and the objects are the main part of the programming.

What is OOPs in java? OOPS in java is to improve code readability and reusability by defining a Java program efficiently. The main principles of object-oriented programming are abstraction, encapsulation, inheritance, and polymorphism. These concepts aim to implement real-world entities in programs.

There are 4 pilers in OOPS. Abstraction Encapsulation Inheritance Polymorphism.

Abstraction: Abstraction refers to hiding implementation details and only showing essential features of an object to the outside world. It is a process of hiding the implementation details from the user, only the functionality will be provided to the user. Abstraction can be achieved through interfaces and abstract classes.

Encapsulation: Encapsulation is the process of wrapping data and behavior (methods) inside a single unit or object. It is a fundamental principle of object-oriented programming that helps to achieve abstraction by hiding implementation details from the outside world. Encapsulation provides a way to secure the data by keeping it private and accessible only through public methods. This helps to maintain the integrity of the data and protects it from unintended modifications, making the code more maintainable and flexible. To implement encapsulation in Java, we use the "private" keyword to declare class variables and methods, and access them through public "getter" and "setter" methods.

Inheritance: Inheritance is a mechanism that allows a class to inherit properties and behaviors from a parent class. The subclass (child class) acquires all the properties and behaviors defined in the parent class and can add new properties and methods or override existing ones. Inheritance enables code reuse and eliminates the need to write the same code again and again. It creates a hierarchy of classes, where a subclass inherits from its parent class, and so on. Java implements inheritance using the "extends" keyword. The parent class is referred to as the superclass, and the subclass is referred to as a subclass. Inheritance is one of the four fundamental concepts of object-oriented programming, along with encapsulation, abstraction, and polymorphism.

Polymorphism: Polymorphism in is the ability of an object to take on multiple forms. It is a fundamental concept of object-oriented programming that enables an object to behave in different ways depending on the context in which it is used. Polymorphism allows objects of different classes to be treated as objects of the same class. This is achieved through method overloading and method overriding. Method overloading allows multiple methods with the same name but different parameters to be defined in a class. Method overriding allows a subclass to provide a different implementation of a method that is already defined in its parent class. Polymorphism makes code more flexible, easier to maintain, and reusable.

Advantages of OOPs Concept Re-usability Data redundancy Code maintenance Security Design benefits Easy troubleshooting.

By using OOP principles, Java enables developers to build complex applications in a modular and organized way, making the code easier to maintain and improve over time.