Page 1 of 1

About Question enthuware.ocpjp.v8.2.1828 :

Posted: Fri Jan 29, 2016 12:01 pm
by pdolezal
A note in the solution to the question tells for an option:
super.methodName(...) is a valid way to invoke a super class's method from anywhere within a subclass's method. But it works only for classes. You cannot invoke the interface's default method using this technique. In fact, if a class (or an interface) overrides a default method of an interface, there is no way to invoke that default method from that class (or interface).
The colored part is incorrect. There is a way to invoke the default method (which may be useful, e.g., when inheriting two different interfaces with the same method and default implementations, or simply when the default is good enough, just needs some decoration):

This code snippet demonstrates it:

Code: Select all

interface Foo {
    default void foo() {
        
    }
}

interface Bar extends Foo {
    default void foo() {
        Foo.super.foo(); // Use the parent interface as the qualifier for 'super'
    }
}

Re: About Question enthuware.ocpjp.v8.2.1828 :

Posted: Fri Jan 29, 2016 9:28 pm
by admin
You are right. This has now been fixed.

thank you for your feedback!
Paul.