Home > Software > Java > Core-Java
Interview Questions   Tutorials   Discussions   Programs   

Core-Java - What is static variable and static method?




299
views
asked marvit September 16, 2014 11:03 AM  

What is static variable and static method?


           

1 Answers



 
answered By Madhumathi   0  

The static keyword is used in java for memory management. We may apply static keyword with variables, methods, blocks and nested class. The static keyword belongs to the class not to the instance of the class.

The static can be:

variable

method

block

nested class

static variable : Is for the class i.e, belongs to class but does not belong to any object . The static variable gets memory only once in class area at the time of class loading.

static method : The static method can not use non static data member or call non-static method directly. This and super cannot be used in static context.

flag   
   add comment

Your answer

Join with account you already have

FF

Preview


Ready to start your tutorial with us? That's great! Send us an email and we will get back to you as soon as possible!

Alert