Monday, 19 September 2011

What is a static method? java interview questions..

Ans:
  • Static variables are always called by the class name.
  • Class variables or static variables are declared with the static keyword in a class. These are declared outside a class and stored in static memory.
  • The scope of the class variable is same an instance variable. 
  • A static variable is associated with the class as a whole rather than with specific instances of a class. Each object will share a common copy of the static variables .
  •  Class variables are mostly used for constants Its initial value is same as instance variable and gets a default value when its not initialized corresponding to the data type.

for more answers click here


No comments: