Can an interface contain static methods in Java?

  • No
  • Only if it doesn't have any abstract methods.
  • Only if it doesn't have any default methods.
  • Yes
Yes, Java allows interfaces to contain static methods, introduced in Java 8. Static methods in interfaces can be called without creating an instance of the interface and are often used for utility functions or factory methods.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *