Posts

Showing posts from January, 2025

Inner Class, Static Inner Class and Anonymous Inner Class

Image
 01) Inner Class In Java, inner class is a class that defined within another class. Inner classes provide better encapsulation, organization and useful when you want to logically group classes that are only used in one place. Inner classes are able to access the outer class's methods and variables, if they are even private. They often used to be readable and maintainable codes. In Java, there are several inner classes among those, the three inner classes that i chose are as below; Normal Inner Class (Non-Static Inner Class) Static Inner Class Anonymous Inner Class 1. Normal Inner Class (Non-Static Inner Class) Inner class is a class that is declared within the outer class. It can access the outer class's methods and variables, even if it is private. Example: class Outer {     private String message = "Hello from Inner Class!";     class Inner {         public void showMessage() {             System.out.println(me...

Blocking and Non-Blocking Operations

Image
Blocking Operations In blocking operations program must wait for a task to complete before moving on to the next task. While it waits, nothing can be happened to the program because it is blocked until the current task is completed.           Real-World Example :- In banks, while we are waiting in the queue we must wait for the person                infront to complete his transaction, we cannot move forward until the person infront completes his            tasks. Non-Blocking Operations In non-blocking operations , it allows a program to engage in other tasks while waiting for the operations to finish. It doesn't block other programs from running. The program has the ability to move forward immediately without waiting for the operation to finish.          Real-World Example :- In a restaurant, while ordering the food we can chat with friends, it is not ...