继承的相关练习

package homework;

public class Instrument 
{
    public void play()
    {
        System.out.println("弹奏乐器");
    }
}
package homework;

public class Wind
{
    public void play()
    {
        System.out.println("弹奏Wind");
    }
    public void play2()
    {
        System.out.println("听,那旋律多美妙");
    }
}
 
package homework;

public class Brass extends Instrument
{
    public void play()
    {
        System.out.println("弹奏Brass");
    }
    public void play2()
    {
        System.out.println("听,那节奏感多强烈");
    }
}
package homework;

public class Music 
{

    public static void main(String[] args)
    {
        Wind w= new Wind();
        w.play();
        w.play2();
        
        Brass b= new Brass();
        b.play();
        b.play2();


    }

}

 

posted @ 2016-09-22 16:14  HRZJ  阅读(173)  评论(0编辑  收藏  举报