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 s = new ISmile();
        s.frown();
        talk(s);
    }

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

class ISmile
{
    void frown()
    {
        System.out.print(" :-@ ");
    }
}

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


:-@  :-0  :-[  :-@  :-@  :-0
:-[  :-0  :-[  :-[  :-@  :-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