1. Using final to decorate a class
Final indicates that the class is the end of the inheritance tree and cannot be inherited.
2. Declare the constructor of the class as private, and then provide a static method to return an object of a class.
The Java language requires that the constructor of the (call) superclass (super Class) be called on the first line in the constructor when inheriting. This is necessary to initiate the inheritance feature. In Java, we do this by calling the super () method, which will map to the constructor of a superclass. If you do not provide a default constructor for the parent class, then the compiler will insert a default superclass widget to invoke. When the constructor of the parent class is declared as private, the compiler will attempt to invoke a default superclass widget when the class is inherited from other classes. Because the component in the superclass scope is declared as private, the compiler will give an error, saying that the superclass component cannot be called. At this point the class is not inherited.
Inheritance of blocking classes in Java