Menu
Question Index
...

What will be the output of the following program?

public class SmileyTest
{
    public static void main(String[] args)
    {
        Smile a = new Smile();

        talk(a);
        a.frown();

        ISmile a1 = new ISmile();
        a1.smile();
    }

    static void talk(ISmile ia1)
    {
        ia1.smile();
        System.out.print(" :-0 ");
    }
}

class ISmile
{
    void smile()
    {
        smile();
    }
}

class Smile extends ISmile
{
    void smile()
    {
        System.out.print(" :-) ");
    }

    public void frown()
    {
        ISmile a1 = new Smile();

        a1.smile();
        System.out.print(" :-[ ");
    }
}


:-)  :-0  :-[  :-)
:-)  :-0  :-)  :-[  :-)
:-)  :-[  :-0  :-)
Compilation Error
Run-time Error

Doubts

Problems

Topic: Creating Interface In Java With Example Program

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App