Menu
Question Index
...

What will be the output of the following program? Assume that all the below classes are in the same package.

public class MERIT
{
    public static void main(String[] args)
    {
            new M().m1();
            new E().m1();
            new R().m1();
            new I().m1();
            new T().m2();
    }
}

class M
{
    private void m1()
    {
        System.out.print("M");
    }
}

class E
{
    protected void m1()
    {
        System.out.print("E");
    }
}

class R
{
    public void m1()
    {
        System.out.print("R");
        new E().m1();
    }
}

class I
{
    void m1()
    {
        System.out.print("I");
    }
}

class T
{
    void m2()
    {
        System.out.print("T");
    }

}


T
MRT
MEREIT
MERIT
Compilation error

Doubts

Problems

Topic: Access Modifiers In Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App