Explain the difference between static and non-static member of a class.A static member has only one copy of instance variables that share among all the objects of the class whereas a non-static member has its own copy of instance variable.What is the difference between Static and Non-Static fields of a class in Java?A static field belongs to a class. The objects of the class can not have the copy of these fields. These fields are referred by the class name. Ex: Employee. company. Without creating an instance of a class, these fields can be accessed.
A non-static field is accessed by all objects of the class. Each object has one copy of non-static field. To use non static fields, an instance of the class should be created.
|