继续浏览精彩内容
慕课网APP
程序员的梦工厂
打开
继续
感谢您的支持,我会继续努力的
赞赏金额会直接到老师账户
将二维码发送给自己后长按识别
微信支付
支付宝支付

运用继承、多态、抽象类编写语言

慕丝2565858
关注TA
已关注
手记 1
粉丝 0
获赞 1

package ex5;

public abstract class Person extends Aperson{
public abstract void say();
}
package ex5;

public class Chinese extends Person {
public void say()
{
System.out.println("Chinese speak Chinese");
}
}
package ex5;

public class American extends Person {
public void say()
{
System.out.println("Americans speak English");
}
}
package ex5;

public class Spain extends Person {
public void say()
{
System.out.println("Spains speak Spanish language");
}
}
package ex5;

public class Initail {

public static void main(String[] args) {
    // TODO Auto-generated method stub
    Person p1=new Chinese();
    Person p2=new American();
            Person p3=new Spain();
    p1.say();
    p2.say();
            p3.say();
}

}`

`

打开App,阅读手记
0人推荐
发表评论
随时随地看视频慕课网APP