Допишите класс, реализующий интерфейс АА, который будет возвращать сумму возвращаемых значений методами а() двух приведенных классов.

interface AA {
    int a();
}

class A implements AA {
    public int a() {
        return 1;
    }
}

class B implements AA {
    public int a() {
        return 1;
    }
}
Explanation
Class implementing an interface cannot narrow access modifier, so method a() has to be public.
Number of parameters cannot change with overriding, a(A a, B b) is a different method. But method a() has to be implemented for correct interface implementation.
Method a() is not static and you need an instance of an object to call it, so A.a() will not compile.

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Keep exploring
Java quizzes
Cosmo
Sign Up Now
or Subscribe for future quizzes