private methods of interface

PHOTO EMBED

Sat Jan 13 2024 22:57:40 GMT+0000 (Coordinated Universal Time)

Saved by @E23CSEU1151 #java

interface D
{
    default void call()
    {
        plus(10,20);
    }
    private void plus(int x,int y)
    {
        System.out.println("plus answer will be "+(x+y));
    }
}
class X implements D
{
    public void subtract(int x, int y)
    {
        System.out.println("subtract answer will be "+(x-y));
    }
}
class C
{
    public static void main(String[] args)
    {
        X r= new X();
        r.call();
        r.subtract(20,10);
    }
}
content_copyCOPY