![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Java is a robust, high level, secure and object-oriented programming language. Oops concept in java, design to improve code readability and reusability by defining a way to structure a Java program efficiently.
Main OOPs concepts in Java are:
Abstraction: Abstraction means using simple things to represent complexity. For e.g. We all know how to turn the TV on, but we don’t need to know how it works in order to enjoy it. In Java, we use abstract class and interface to achieve abstraction.
Encapsulation: This is the practice of keeping fields within a class private, then providing access to them via public methods. For example, capsule, it is wrapped with different medicines. A Java class is the example of encapsulation.
Inheritance: When one object obtains all the properties and behaviors of a parent object, it is known as inheritance. It provides code reusability. It is used to achieve runtime polymorphism.
Polymorphism: If one task is executed in different ways, it is known as polymorphism. For example: to satisfy the customer differently, to draw something, like; the shape of a triangle, rectangle, etc. In Java, we have two types of polymorphism: Method overloading and method overriding.