• 코드:
​x
 
1
interface Animal { public abstract void cry(); }
2
​
3
class Cat implements Animal {
4
    public void cry() {
5
        System.out.println("냐옹냐옹!");
6
    }
7
}
8
​
9
class Dog implements Animal {
10
    public void cry() {
11
        System.out.println("멍멍!");
12
    }
13
}
14
​
15
public class prog {
16
    public static void main(String[] args) {
17
        Cat c = new Cat();
18
        Dog d = new Dog();
19
        
20
        c.cry();
21
        d.cry();
22
    }
23
}
표준입력 & 실행옵션