Explain Static variable

Static variable: It is a static variable defined within a class body. Such a variable fits in to the class as a whole, and is, thus, shared by all objects of the class. The class variable may be employed to define the default value of an instance variable, for illustration, and would probably as well be stated as final, too. They are too employed to contain dynamic information which is shared among all instances of a class. For instance the later account number to be assigned in a bank account class. The care should be taken to make sure that access to share the information, like this is synchronized where multiple threads could be included. Class variables are too employed to provide names to application-wide values or objects as they might be accessed directly through their containing class name instead of an instance of the class.

   Related Questions in Programming Languages

©TutorsGlobe All rights reserved 2022-2023.