-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAnimalEx01.java
More file actions
63 lines (47 loc) · 783 Bytes
/
Copy pathAnimalEx01.java
File metadata and controls
63 lines (47 loc) · 783 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package java4;
class Animal{
void sound() {
}
}
class Dog extends Animal{
//무효화시키다.
void sound() {
System.out.println("멍멍");
}
}
class Cat extends Animal{
//무효화시키다.
void sound() {
System.out.println("야옹");
}
}
class Bird extends Animal {
//무효화시키다.
void sound() {
System.out.println("짹짹");
}
}
class Tiger extends Animal{
void sound() {
System.out.println("어흥");
}
}
class Cow extends Animal{
void sound() {
System.out.println("음메");
}
}
public class AnimalEx01 {
//Animal b = new Bird();
static void play(Animal b) {
b.sound();
}
public static void main(String[] args) {
Bird b1= new Bird();
play(b1);
Cat c1= new Cat();
play(c1);
play(new Dog());
play(new Tiger());
}
}