0

You often hear that methods in an interface have no implementation. However, in Java 8 it became possible to implement the default methods. But I'm interested. Was and is it possible to implement interface methods natively? (native methods).

When the interview question is asked - "Is it possible to implement a method in an interface?" Answer - you can make a native method implementation, and since Java 8 it is possible to define a default method." How correct is this answer?

John Kugelman
  • 349,597
  • 67
  • 533
  • 578
stfxc
  • 174
  • 6

1 Answers1

6

No, interfaces can't have native methods:

Note that an interface method may not be declared [..] with the modifiers final, synchronized, or native.

Technically that text is non-normative, because it only points out that this list does not contain the mentioned modifiers:

InterfaceMethodModifier:
    (one of)
    Annotation public private
    abstract default static strictfp

Joachim Sauer
  • 302,674
  • 57
  • 556
  • 614