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` introduces `“Default Method”`new feature, which allows
>  developer to add new methods to the interfaces without breaking the
>  existing implementation of these interface. It provides flexibility to
>  allow interface define implementation which will use as default in the
>  situation where a concrete class fails to provide an implementation
>  for that method.
> 
> 
> 

Refer [this](https://docs.oracle.com/javase/tutorial/java/IandI/defaultmethods.html) for more.