01: /*
02: * MethodInvoker4.java --
03: *
04: * tcljava/tests/signature/MethodInvoker4.java
05: *
06: * Copyright (c) 1998 by Moses DeJong
07: *
08: * See the file "license.terms" for information on usage and redistribution
09: * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
10: *
11: * RCS: @(#) $Id: MethodInvoker4.java,v 1.2 2002/12/27 14:33:20 mdejong Exp $
12: *
13: */
14:
15: package tests.signature;
16:
17: import java.util.*;
18:
19: public class MethodInvoker4 {
20:
21: public static String call(A obj) {
22: return "A";
23: }
24:
25: public static String call(I obj) {
26: return "I";
27: }
28:
29: public static interface I {
30: }
31:
32: public static class A {
33: }
34:
35: public static class B implements I {
36: }
37:
38: public static A getA() {
39: return new A();
40: }
41:
42: public static B getB() {
43: return new B();
44: }
45:
46: public static I getI() {
47: return new B();
48: }
49:
50: public static void main(String[] argv) {
51:
52: A a = getA();
53: B b = getB();
54: I i = getI();
55:
56: String s;
57:
58: s = call(a); //should return "A"
59: p(s);
60:
61: s = call(i); //should return "I"
62: p(s);
63:
64: s = call(b); //should return "I"
65: p(s);
66:
67: }
68:
69: public static void p(String arg) {
70: System.out.println(arg);
71: }
72:
73: }
|