Ads Sponsored By Google :)

Wednesday, 30 January 2013

difference between static block|and|vs|main|method in java with example


static block vs static method static block vs static method in java difference between static block and static method static block and static method in java with example static block vs main method difference between static block and static method in java static block and main method in java difference between static block and main method  difference between static block and main method in java static block vs main method in java difference between static block and main method in java with example static block vs main method in java with example difference between static block and static method with example


Static block Vs Static Method Vs Main Method:

  Static Block:

        Static Block is execution starts first  then main method will executes.  
       Static Block execution is not dependent on main method. 
       It is not included in any other method. It is used for Initialization of static members. 
       static{} block is not inside any method. Static block will get executed only 
       once while loading the class.

Static Data Members(Method and variable):

     Static Data members execution is depends on class not on object, because it is a part 
 of class. Hence accessing of static data members as follows.

Syntax:   
          classname.staticdatamember;

  To know About Static variable and static method

Main method:
    Main method is starting point of executing instance data members, not for static data members.


Order of execution of Static variable ,static block and  static method





1 comment:

LinkWithin