Exception Handling in Java

In the previous blog, we understood what exceptions mean. But how do we stop exceptions from crashing our application?? In this blog, we will find the answer to this question. try-catch-finally Let us see try-catch-finally in action. Note: Although finally block contains important clean-up code(like closing a database connection), it is optional. There can be … Read more

Exceptions in Java

An exception is an abnormal path of execution of code that the developer must handle. Ok…then what is an error? An error is an unexpected situation outside the control of the code that the developer should not try to handle.An error may be caused due to environmental factors, hardware/virtual machine failures, etc. None of these … Read more

Encapsulation in Java

Encapsulation is the hiding of data and code from outside interference.The data and code can only be accessed/modified by the class in which it is defined. This is achieved by declaring the variables as private and getters/setters as public. Note: private and public are access specifiers about which we will talk a little later. The … Read more

Polymorphism and its types in Java

Polymorphism is a feature in OOP by which an entity can exhibit itself in multiple forms. In Java, polymorphism can be achieved in the following ways Now let’s understand what each of these means. Run-time Polymorphism Run-time polymorphism is resolved by JVM(Java Virtual Machine) during execution and hence the name run-time polymorphism. Run-time polymorphism is … Read more

Abstraction and its types in Java

Abstraction and its types in Java

Abstraction is the process of hiding the implementation details of a class or method and showing only the functionality to the user. Note: Although we cannot create objects for abstract classes, we can extend abstract classes using a non abstract class and create objects for the non abstract class. So…what are the ways to achieve … Read more

Inheritance and its types in Java

Inheritance and its types in Java

Inheritance is a concept of using the methods and attributes of one class(superclass/base class) into another(child class/subclass) with the help of the “extends” keyword. The concept of inheritance allows us to achieve code reusability and method overriding. Let’s see the syntax for Inheritance: Let’s see an example of Inheritance Output: Types of Inheritance Types of … Read more