I have a doubt
//Interface A
code:
--------------------------------------------------------------------------------
interface A{public void add();public void sub();public void multiplication();} //Class B that Implements Aclass B implements A{public void add(){ int a=30; int b=40; int c=a+b; System.out.println("The result of Addition is:-"c); }public void sub(){ int a=80; int b=40; int c=a-b; System.out.println("The result of Substraction is:-"c);}public void multiplication(){ int a=80; int b=40; int c=a*b; System.out.println("The result of Multiplication is:-"c);}public void division(){ int a=80; int b=40; int c=a/b; System.out.println("The result of Division is:-"c); }}//Anaother class C that use B's methodclass C{public static void main(
String[]args){ //what is the differnce //I have a doubt why we use this line A a=new B(); a.add(); B b=new B(); b.add(); }}
--------------------------------------------------------------------------------
I have a doubt,In class C I am accessing the B's add()through 2 referance variables one is class type and another is interface type.ok
My doubt is what's the differance?
which is adviceable to use?
thanks
Biswo