package zhongqiuzuoye; public class Instrument { public void play()
{
System.out.println("弹奏乐器");
} }
package zhongqiuzuoye; public class Wind extends Instrument{ public void play()
{
System.out.println("弹奏wind");
}
public void play2()
{
System.out.println("调用wind的play2");
} }
package zhongqiuzuoye; public class Brass extends Instrument{ public void play()
{
System.out.println("弹奏brass");
}
public void play2()
{
System.out.println("调用brass的play2");
}
}
package zhongqiuzuoye; public class Music { public static void tune(Instrument i){
i.play();
}
public static void main(String[] args)
{
Instrument i= new Instrument();
i.play();
Wind w= new Wind();
w.play();
w.play2(); Brass b= new Brass();
b.play();
b.play2();
}
}