I was going through the concept of final class in java which says final class can't be inherited in java. However, if we can make all the methods of class as final and all the variables as private, won't it create the same effect as that of declaring class as final?
Take the following scenario:
Let me describe my question bit more, One of the key requirements to make class immutable is- Class should be declared as final. All variables should be final (and initialized via constructors)
Can we achieve this immutability requirement by making all methods of class as final and declaring all variables as private and final, to achieve this condition for immutability?
So, even if the class can be inherited now, we can't override the methods (as methods are final) and we can't change the variables of super class (as they are final and also not visible - private).