Menu
Question Index
...

What will be the output of the following program?

class OuterClass {
    void display() {
        System.out.println("ourter");
    }
}

public class DemoOnOuter {
    public static void main(String[] args) {
        new DemoOnOuter().dispaly();
    }
    void dispaly() {
        new OuterClass().display();
        class OurterClass {
            void display() {
                System.out.println("inner");
            }
        }
    }
    class OuterClass {
        void display() {
            System.out.println("middle");
        }
    }
}


outer
inner
middle
middleinnerouter
Some other output
Compilation Error or Runtime Error

Doubts

Problems

Topic: Calling A Class From Another Class 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