您的位置:首页 > 其它

day3--面向对象--interface

2015-07-18 11:44 507 查看
package day04;

class Animal2{
private String name;
private int age;

public Animal2(String name, int age) {
this.name = name;
this.age = age;
}

public void say() {
System.out.println(name + "," + age);
}
}

interface Bellow {
public void bellow();
}

interface Work {
public void work();
}

class Dog1 extends Animal2 implements Bellow, Work {
public Dog1() {
super("狗", 1);
}

public Dog1(String name, int age) {
super(name, age);
}

public void bellow() {
System.out.println("汪汪汪");

}

public void work() {
System.out.println("看家");
}
}

public class Demo6 {

public static void main(String[] args) {
Dog1 d=new Dog1();
d.bellow();
d.work();

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: