Static keyword in java, by inheritance

Java Programming Language / Class, Object and Methods in java

3676

Program:

 class Methods{
  static int add(int a,int b) {

    return (a+b);
  }

  static void show() {
    System.out.println("show method");
  }
}

class StaticMethod extends Methods{
  public static void main(String[] args)
  {
    int result =add(6, 7);
    System.out.println("Result is:" + result);
    show();
   }
}

Output:

Result is:13
show method
Press any key to continue . . .

This Particular section is dedicated to Programs only. If you want learn more about Java Programming Language. Then you can visit below links to get more depth on this subject.