//上转型对象2
abstract class P
{
public abstract void f(int x);
public abstract void g(int x,int y);
public abstract void h(double x);
}
class S1 extends P
{
public void f(int x)
{
System.out.printf("我是S1的f,%d\n",x);
}
public void g(int x,int y)
{
System.out.printf("我市S1的g,%d,%d\n",x,y);
}
public void h(double x)
{
System.out.printf("我是S1的h,%f\n",x);
}
}
class S2 extends P
{
public void f(int x)
{
System.out.printf("我是S2的f,%d\n",x);
}
public void g(int x,int y)
{
System.out.printf("我市S2的g,%d,%d\n",x,y);
}
public void h(double x)
{
System.out.printf("我是S2的h,%f\n",x);
}
}
class S3 extends P
{
public void f(int x)
{
System.out.printf("我是S3的f,%d\n",x);
}
public void g(int x,int y)
{
System.out.printf("我是S3的g,%d,%d\n",x,y);
}
public void h(double x)
{
System.out.printf("我是S3的h,%f\n",x);
}
}
public class Main
{
public static void main(String[] args)
{ int x=10,y=20;
double z=30;
P p;
p=new S1();
p.f(x);
p.g(x,y);
p.h(z);
p=new S2();
p.f(x);
p.g(x,y);
p.h(z);
p=new S3();
p.f(x);
p.g(x,y);
p.h(z);
}
}