Friday, July 30, 2010

Java Static Function

Q. Can we override the Static function in Java ?
A. Yes we can override the Static function in Java see the sample recipe

class Sample implements Over {

public static int simple(int a, int b) {
int c = a + b;
return c;
}
}
class Overloading extends Sample {

public static int simple(int a, int b) {
int c = a * b;
return c;

}
public static void main(String[] args) {
        Sample sam = new Sample(22, 90);
        Overloading obj = new Overloading();
          obj.simple(10,20); // here the sub class function call
         sam..simple(10,20); // here the super class function call
}
}


No comments: