Monday, 12 March 2018

Types of Inheritance Single & multilevel inheritance in java





package javaapplication13;



class calculator1

{

   

public int sum(int a,int b)

{

return a+b;

}





}





class calculator2 extends calculator1

{

   

public int sub(int a,int b)

{

return a-b;

}

   

   

}





class calculator3 extends calculator2

{

   

public int mul(int a,int b)

{

return a*b;

}

}











public class JavaApplication13 {



   

    public static void main(String[] args)

    {

   int r;

    calculator2 c=new calculator3();

   r= c.sum(9, 9);

   System.out.println(r);

   r=c.sub(9,9);

   System.out.println(r);

 

   

    }

   

}



No comments:

Post a Comment

Pass Dynamically Added Html Table Records List To Controller In Asp.net MVC

Controller Code: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using ...