Ads Sponsored By Google :)

Sunday 27 January 2013

static method in java with example factory|synchronized interface|means|tutorial can we override|overload


static method in java can we override static method in java can we overload static method in java
static method in java interface static method in java means static method in java with example
static method in java tutorial static factory method in java example static synchronized method in java
static methods in java  static methods in java example static method in java tutorial with example

Static Method:

     1)  Static methods are recommended to perform one time operations such as opening 
           file in read mode or write mode, obtaining data base connection etc…
     2)  Static methods are meant for performing common operations.
     3)  Programmatically static methods are preceded by static keyword.

   Syntax:
    
        Static return-type method-name(number of parameters)
      {
           ------------------  //Block of statements
         ------------------  // Block of statements
       }
    4)  Each and every static method must be accessed w.r.t classname.
     Classname.staticmethodname();

         static synchronized method in java?

      The following program illustrate the concept of Static data member:
      
        Class staticDemo
       {
          static int x=10;
          static void fun1()
        {
           System.out.println(“this is static function”);
         }
       }
       Class oneclass
     {
        void   fun2();
       {
         staticDemo.fun1();
        System.out.println(“The value of x”+staticDemo.x);// calling static data member using  
                                                                                           //class name
       }
         public static void main(String args[])
       {
           oneclass obj=new oneclass();
           obj.fun2();
       }
     }

No comments:

Post a Comment

LinkWithin