Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class E {
- interface X { void f(); }
- class B {
- public void g() { System.out.print("B.g() "); }
- }
- public static void main(String[] Args) {
- class C extends B implements X {
- public void f() { System.out.print("C.f() "); }
- public void f(Object ref) { System.out.print("C.f(Object) "); }
- }
- abstract class A extends B implements X {
- public void f() { System.out.print("A.f() "); }
- public void g() { System.out.print("A.g() "); }
- public abstract B f(B ref);
- }
- class D extends A {
- public static B st = new B();
- public void f() { System.out.print("D.f() "); }
- public B f(B ref) { if (ref instanceof A) return (D)ref; return st; }
- }
- A a = new D();
- B b = a;
- b.g();
- a.g();
- a.f(b);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement