Question: While writing interface in java 8 i noticed behavior that i was able to define method in interface without any compile time error.

```
public interface AdvanceMediaPlayer {
    public static void playVlc(String fileName) {
        System.out.println("play VLC");
    }
    public abstract void playMp4(String fileName);
}

```

Please explain why is this happening. As far as I am aware we cant implement methods inside interfaces.

Answer: 
Java8 provides the ability to create default method implementations:

<https://docs.oracle.com/javase/tutorial/java/IandI/defaultmethods.html>
Java 8 makes you able to declare static and default methods in interfaces.

A static interface method can not be overridden by the implementing class. It can only be called like this:

```
AdvanceMediaPlayer.playVlc(fileName);

```

A default method can be overridden by the implementing class. It is declared with the `default` keyword.