Skip to main content

Posts

Showing posts with the label Java Static variable

Java - Static variable, static method and static block with example.

Java Static keyword, Static method and Static block........ Questions.......?? 1) What is static keyword , static method() , static block 2) Define static keyword , static method() , static block 3) What do you mean by static keyword , static method() , static block 4)static keyword , static method() , static block in Java ?     1)Static Keyword:- Static keyword in Java Programming language is used for memory management purpose, it indicates that a particular member belong to a type itself, rather than to an instance of that type. As we mentioned above that is used for memory management purpose it means that static keyword gets memory once in the class which help in reduction of the memory, which makes the execution speed of the program fast which is a great advantage of the static keyword. let's take example how static keyword works..... firstly we will see how memory get wasted when we didn't use the static keyword. class company {  int emp_id;