Tuesday, 29 August 2017

core Java Program to how a method can invoke a super class method

W.A.P that illustrate how method can invoke a super class method.

There is one supercalss A.

class B extends class A and class C extends class B.

Each of these classes define a getdescription() method that returns a string.

That string includes description of the class plus description of each super class.

Inherits each of these class and invoke the gerdescription() method.

Program

class a{
          String disdata()
          {
                   return "class A:";
          }
}
class b extends a{
          String disdata()
          {
                   return ("class B:"+super.disdata());
          }
}
class c extends b{
          String disdata()
          {
                   return ("class c:"+super.disdata());
          }
}
class call{
          public static void main(String args[])
          {
                   c objC = new c();
                   System.out.println(objC.disdata());
          }

}

Output

super class method java core

0 comments:

Post a Comment