Java Reference
In-Depth Information
for (int i = 0; i < elements.length; i++) {
elements[i].method2();
System.out.println(elements[i]);
elements[i].method1();
System.out.println();
}
}
9. Assume that the following classes have been defined:
1 public class Flute extends Blue {
2 public void method2() {
3 System.out.println("flute 2");
4 }
5
6 public String toString() {
7 return "flute";
8 }
9 }
1 public class Blue extends Moo {
2 public void method1() {
3 System.out.println("blue 1");
4 }
5 }
1 public class Shoe extends Flute {
2 public void method1() {
3 System.out.println("shoe 1");
4 }
5 }
1 public class Moo {
2 public void method1() {
3 System.out.println("moo 1");
4 }
5
6 public void method2() {
7 System.out.println("moo 2");
8 }
9
10 public String toString() {
11 return "moo";
12 }
13 }
Search WWH ::




Custom Search