1. Thread-Safe Singleton Design Pattern in Java
Bill Pugh Singleton Implementation using static inner helper class:
public class Singleton {
private Singleton() {}
private static class SingletonHelper {
private static final Singleton INSTANCE = new Singleton();
}
public static Singleton getInstance() {
return SingletonHelper.INSTANCE;
}
}
2. Abstraction vs Polymorphism Example
Demonstrating Method Overriding (Runtime Polymorphism) and Abstract Classes:
abstract class Developer {
abstract void code();
}
class JavaDeveloper extends Developer {
@Override
void code() {
System.out.println("Coding in Java & Spring Boot — Manish Kumar");
}
}