Menu
Question Index
...

What will be the output of the following program?

public abstract class AbstractTest
{
    public int getNum()
    {
        return 45;
    }

    public abstract class Bar
    {
        public int getNum()
        {
            return 38;
        }
    }

    public static void main (String [] args)
    {
        AbstractTest t = new AbstractTest()
        {
            public int getNum()
            {
                return 22;
            }
        };

        AbstractTest.Bar f = t.new Bar()
        {
            public int getNum()
            {
                return 57;
            }
        };
        System.out.println(f.getNum() + " " + t.getNum());
    }
}


45 57
45 38
57 22
Compilation Error
Runtime Error

Doubts

Problems

Topic: Rules For Abstract Methods and Abstract Classes

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App