What is meant by static variable and static method

Showing Answers 1 - 6 of 6 Answers


  • Sep 8th, 2005

both are class member n belong to defined class n object of class can;t access them  

  Was this answer useful?  Yes


  • Sep 22nd, 2005

Static means no need of object.So either it is a static variable or static method no need to create an object of it.jst invoke by the class name.Static variable also posses the quality to have the scope of method in which it is declared& lifetime till prg. is executing.Static variable is initialised only 1 time in complete prg. execution.Ex.int count(){static int a=1;a+=1;}If a prg is ruuning & calling count for 10 times then the count atlast will be 10 only not 2as static make it to initialise only for the 1st time & then the either the variable scope ended its value remains due to lifetime which equals the app. execution.static methods r methods that can be called onlt from static methods with class name.B'coz of this reason only main method is static as we dont need to make an obj. of class to invoke it from commandline.We do that from class name only & thats the reason we always name the main class the same with which we save it.


  • Oct 8th, 2005

         Static means only one copy exists for the entire class irrespective of the number of objects tat exists for tat class.

        Memory for the static members is created before the object is created,becoz of this they can be called only with the class name.

          Static variables can be accessed only in static methods.



  Was this answer useful?  Yes


  • Aug 31st, 2006

its wrong

static variables can also be accessed in non-static methods


  • Mar 22nd, 2007

In java static means common to class not specific to Objects.So static variables and static methods are accessible only by class name and not by objects.

  Was this answer useful?  Yes


  • Jun 6th, 2007

Please Check with this example program

public class StaticExam {

int a=10;

public static void main(String args[])


System.out.println(" Welcome to static variable testing");StaticExam s= new StaticExam();



public void display()


System.out.println(" The value of static variable is " +a);



  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.


Related Answered Questions


Related Open Questions