Friday, 17 February 2017

Default Method : Simple Program

interface A
{
    public void disp();    default void def()
    {
        System.out.println( "default() method called" );    }
}
public class DefaultMethod implements A {

    @Override    public void disp()
    {
        System.out.println( "disp() method called" );    }

    public static void main(String[] args)
    {
        DefaultMethod defaultMethod = new DefaultMethod();
        defaultMethod.disp();        defaultMethod.def();
    }
}

No comments:

Post a Comment