OOP principles in JAVA
All object-oriented programming (OOP) languages introduced mechanisms that help you implement the object-oriented techniques. OOP principles in JAVA are inheritance, encapsulation, and polymorphism. Now we’ll discuss in detail one by one.
Inheritance is a technique where one object of the class acquires the properties or state of another object called Inheritance. This is most important in concepts of OOP programming. In the inheritance technique, there are the most important rules of parent class and child class or subclass. Information is made manageable in a hierarchical sequence using inheritance techniques. All subclasses or child classes can inherit the properties or state of an object from its parent classes. In inheritance, an object needs only define those attributes that make it unique within its class. It can inherit its general attributes from its parent class.
Parent Class: a class whose properties used in another class called parent class, base class, or superclass.
Child Class: a class which inherits the properties or contents of another class called child class, subclass or derived class.
Encapsulation is a technique in OOP programming where the one class data or information hide from another class called encapsulation. In simple words, encapsulation is the data hiding technique. In the capsulation technique, there are some mechanisms for hiding the complexity of the implementation codes inside the class. In a class, every variable or method may be marked as public or private. The public
The word polymorphism is a combination of two poly and morphism. Poly meaning many and morphism mean form. In object-oriented programming, polymorphism is the ability of objects of different types to respond to function of the same name. The user does not have to know the exact type of the object in advance. The behavior of the object can be implemented at the run time. It is called dynamic binding or late binding. Function overloading and function overriding are the two main things for the implementation of polymorphism techniques.