Poly

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

package Rattrappage2014 ;

class A {
public void test (int i1, int i2) {
System.out.println ("A.test(int, int)") ;
}
}

class B extends A {
public void test (float f, int a) {
System.out.println ("B.test(float, int)") ;
}
public void test (float f1, float f2) {
System.out.println ("B.test(float, float)") ;
}
public void test (int i, float f) {
System.out.println ("B.test(int, float)") ;
}
}

class C extends B {
public void test (int i1, int i2) {
System.out.println ("B.test(int, int)") ;
}
public void test (int a, double d) {
System.out.println ("C.test (int, double)") ;
}
public void test (float f1, float f2) {
System.out.println ("B.test(float, float)") ;
}
public void test (double d1, double d2) {
System.out.println ("C.test (double, double)") ;
}
}

public class Polymorphisme


{ public static void main (String args[])
{
A aA = new A () ;
A aC = new C () ;
B bC = new C () ;
C cC = new C () ;

bC.test (0, 0) ; //instruction 1


bC.test (5f, 0l) ; //instruction 2
cC.test (0f, 0) ; //instruction 3
aC.test ((byte)5, 10) ; //instruction 4
aA.test (0.f, 0.f) ; //instruction 5
cC.test (1.f, 0) ; //instruction 6
}
}

FIGURE 1. Polymorphisme

You might also like