Inheritance is one of the core principles of object-oriented programming (OOP), which help us derive a class from another class or a hierarchy of classes that share a set of attributes and methods. In other words, it is a relationship between a superclass (a more generalised class) and a subclass (a more specialised class), where the subclass inherits data and behavior from the superclass.
In Java, abstraction is implemented using abstract class and interface, which are two categories in Java with different rules and properties. An abstract class appears similar to any other class, but it is declared with the abstract keyword, and one can never instantiate an abstract class.
Learning Object-Oriented Programming is essential for modern software development as it introduces many features such as Inheritance, Encapsulation, Abstraction, and Polymorphism. Besides reducing code complexity, the oops provide other advantages like code modularity, code reusability, code extensibility, data hiding, etc.
The word “interface” means a medium or means of communication between two entities. Similarly, in Java, interfaces are used to ease the communication between various classes. An interface looks similar to any class and contains only constants, method signatures, default methods, and static methods.
An exception is an event that occurs during the execution of a program and disrupts the normal (expected) flow of the program. The word “exception” in programming refers to an “exceptional event.” As soon as the exception is thrown, the runtime system attempts to find an exception handler.
In OOP, Polymorphism allows us to code to an interface and has multiple implementations, making the program better. In Java, there are two types of polymorphism: Compile-time and Runtime polymorphism. The first type is implemented with method overloading, and the second one is implemented via method overriding.