Link to home
Start Free TrialLog in
Avatar of SunScreenCert
SunScreenCert

asked on

How can this program allow two class A implements Foo

package test1;

interface Foo {
       int bar();
       }
      
       public class Beta {
      
       class A implements Foo {
       public int bar() { return 1; }
       }
      
       public int fubar( Foo foo ) { return foo.bar(); }
      
       public void testFoo() {
      
       class A implements Foo {
       public int bar() { return 2; }
       }
       System.out.println( fubar( new A() ) );
       }
      
       public static void main( String[] argv ) {
       new Beta().testFoo();
       }
       }
ASKER CERTIFIED SOLUTION
Avatar of Kevin Cross
Kevin Cross
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial