-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBird.java
More file actions
44 lines (40 loc) · 1.09 KB
/
Bird.java
File metadata and controls
44 lines (40 loc) · 1.09 KB
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
package tracing_exercise;
public class Bird {
public static void main(String args[]) {
System.out.println("zero");
Bird s = new SillyBird(1);
Bird s2 = new Loony();
s.poit(s2);
s2.poit(s);
System.out.println("zymurgy");
}
public Bird() {
this(0);
System.out.println("zircon");
}
public Bird(int i) { System.out.println("zanzibar"); }
public void narf() { System.out.println("zort"); }
public void poit(Bird s) { s.narf(); }
}
class SillyBird extends Bird {
public SillyBird(){
//super(); //non effective! is automatically called when accessed.
System.out.println("duchess");
}
public SillyBird(int i) {
super(i);
}
public void narf() {
System.out.println("drum");
super.narf();
}
}
class Loony extends SillyBird {
public Loony() {
//super(); //non effective! is automatically called when accessed.
System.out.println("stupendous");
}
public void narf() {
System.out.println("snark");
}
}