Which class is super class of every class

Why no global variables in Java ?

Answer : Java doesn’t supports global variables by design. Probably they think it could be difficult to maintain or error prone. It was designed with object oriented principles in mind that every variable in Java be either local or a member of a class.

Java designer has created static modifier which you can use to create global variable.Java’s lack of support for global variables is a good thing, as using global variables is a design anti-pattern.

Leave a Reply

Your email address will not be published. Required fields are marked *