What is a final modifier? Explain other Java modifiers?

A final class can’t be extended i.e. A final class can not be subclassed. A final method can’t be overridden when its class is inherited. You can’t change value of a final variable (i.e. it is a constant). Modifier Class Method Variable static A static inner class is just an inner class associated with the class, rather than with an instance of the class. A static method is called by classname.method (e.g Math.random()), can only access static variables. Class variables are called static variables. There is only one occurrence of a class variable per JVM per class loader. abstract An … Click here to continue…..

Where and how can you use a private constructor?

Private constructor is used if you do not want other classes to instantiate the object and to prevent subclassing. The instantiation is done by a public static method (i.e. a static factory method) within the same class. Used in the singleton design pattern. Used in the factory method design pattern e.g. java.util.Collections class Used in utility classes e.g. StringUtils etc.