Which TWO statements about methods declared in an interface are true in Java 25? (Choose two.)
A. An interface may declare a private static method, and both static and default methods of that interface may call it.Correct answer
Correct: private interface methods exist to factor out shared code, and a private static method can be called unqualified from both the interface's static and default methods.
B. A default method may be declared final so that implementing classes cannot override it.
Incorrect: a default method may not be declared final — the modifier is rejected outright, because a default method is always overridable by an implementing class or subinterface.
C. A class that implements two unrelated interfaces which each supply a default method with the same signature does not compile unless it overrides that method.Correct answer
Correct: this is the diamond rule — a class inheriting two unrelated default methods with the same signature does not compile until it overrides that method (optionally disambiguating with X.super.tag()).
D. A static interface method is inherited by an implementing class and may be invoked through that class's name.
Incorrect: static interface methods are not inherited, so they cannot be invoked through an implementing class's name — you must call them through the interface name.
Explanation
Why `An interface may declare a private static method, and both static and default methods of that interface may call it.` is true: private interface methods (static and instance) exist to factor out shared code without exporting it. An interface with `private static String secret()`, a `static String viaStatic()` calling it, and a `default String viaDefault()` calling it compiles and runs, printing `s1 s2`. A private *instance* method needs a receiver, so a static method of the interface can call it only on an explicit instance (`s.inst()`), never unqualified; a private *static* method can be called unqualified from both.
Why `A class that implements two unrelated interfaces which each supply a default method with the same signature does not compile ...` is true: this is the diamond rule. With `interface X { default String tag() {...} }` and `interface Y { default String tag() {...} }`, `class Impl implements X, Y { }` fails with `types X and Y are incompatible; class Impl inherits unrelated defaults for tag() from types X and Y`. The class must override `tag()`, and inside the override it may disambiguate with `X.super.tag()`.
Why the others are wrong:
`A static interface method is inherited by an implementing class ...` encodes the belief that interface statics behave like class statics. They do not: static interface methods are not inherited. Calling `Impl.tag()` where `Util` declares `static tag()` fails with `cannot find symbol ... location: class Impl`; you must write `Util.tag()`.
`A default method may be declared final ...` assumes default methods are ordinary virtual methods you can seal. `final default String tag()` is rejected outright with `modifier final not allowed here` — a default method is always overridable, which is why a subinterface or class can always replace it.
Exam tip: interface method modifiers are a short list — `public`/`abstract` (implicit), `default`, `static`, `private`, `private static`. `final`, `synchronized`, and `protected` are all illegal on an interface method. The reverse trap: interface *fields* are implicitly `public static final`, so the word `final` is fine there and only illegal on methods.