Which class that implements the interface AA and returns the amount of the return value of a() of two given classes is declared correctly:

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.

Следи за CodeGalaxy

Мобильное приложение Beta

Get it on Google Play
Обратная Связь
Продолжайте изучать
тесты по Java
Cosmo
Зарегистрируйся сейчас
или Подпишись на будущие тесты