• 코드:
​x
 
1
interface Animal { public abstract void cry(); }
2
interface Pet { public abstract void play(); }
3
​
4
class Cat implements Animal, Pet {
5
    public void cry() {
6
        System.out.println("냐옹냐옹!");
7
    }
8
    public void play() {
9
        System.out.println("나비야~ 쥐 잡기 놀이하자~!");
10
    }
11
}
12
​
13
class Dog implements Animal, Pet {
14
    public void cry() {
15
        System.out.println("멍멍!");
16
    }
17
    public void play() {
18
        System.out.println("바둑아~ 산책가자~!");
19
    }
20
}
21
​
22
public class prog {
23
    public static void main(String[] args) {
24
        Cat c = new Cat();
25
        Dog d = new Dog();
26
        
27
        c.cry();
28
        c.play();
29
        d.cry();
30
        d.play();
31
    }
32
}
표준입력 & 실행옵션