DEV Community

Artavazd
Artavazd

Posted on

Java

ENCAPSULATION IN OBJECT ORIENTED PROGRAMMING-The idea of encapsulation aims to keep external parties from knowing how objects are implemented. It claims that all relevant data is internal to the object and that only a subset of the data is accessible externally. The internal workings and state of each object are kept confidentially within the designated class; other objects cannot access or modify it. Rather, they are limited to using a select few public services or features. This type of data hiding lowers the possibility of errors, increases program understandability, and gives program security and control over object state changes.

iNHERITANCE IN OBJECT ORIENTED PROGRAMMING-The concept of inheritance gives programmers the ability to build new classes based on pre-existing (parent) classes and modify or add new methods and properties as needed. This helps to avoid code duplication and makes maintenance easier for programs with thousands of lines of code. Developers can construct objects with similar code or logic but distinct properties by leveraging the parent class's logic in the child class. As a result, the code becomes less complex and there is no longer a need to create a new object for every object that the program uses.

POLYMORPHISM IN OBJECT ORIENTED PROGRAMMING- In addition to inheritance, polymorphism allows objects of different classes to carry out identical actions with different code. For example, a variety of information about objects of the "car," "plane," or "ship" type can be displayed using the "show information" method. Moreover, polymorphism facilitates the development of modular and flexible programs. In general, it makes development easier because it makes it possible to create shared functions and methods that can be applied to a variety of object types.

ABSTRACTION IN OBJECT ORIENTED PROGRAMMING- Abstraction allows you to focus on the essential elements of a system while ignoring the less important details that have no bearing on its key features. It enables you to create more understandable programs. Abstraction can be considered an extension of encapsulation. Take, for example, programs with thousands of lines of code. Each object only reveals a specific mechanism for usage due to the principle of abstraction. As a result, the code contained within becomes largely independent of other objects. For example, in a program that stores movie information, you can create a class "Movie" that allows you to access only the most important details, such as title, release year, and genre, while hiding less important information, such as shots or technical aspects.

Top comments (0)