Menu
Topics Index
...
`

Classes inside the class1638


If you need explanation Read this topic

If you need Answer Take test on this topic

Classes inside the class1638
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");
        }
    }
}

A. outer
B. inner
C. middle
D. middleinnerouter
E. Some other output
F. Compilation Error or Runtime Error
Topic: Calling A Class From Another Class In Java

If you need explanation Read this topic

If you need Answer Take test on this topic

User comments below. All of them might not be correct.

ans is C: the middle outer class will act as a member of DemoOnOuter and display() fun defined in it will call diplay() of middle outer class through its object... second preference would be to that of outermost class

Posted by Sarika Vollala    2013-07-26 09:07:28


ans should be B as it should call display of the inner cls...

Posted by Pramod Jain    2013-07-26 09:14:40


E

Posted by Naveen Kumar    2013-07-26 10:46:11


a

Posted by Aruna Dantu    2013-07-26 14:17:34


E is the correct answer because compiler cannot find the display method in the outer class

Posted by Ram Reddy Bitla    2013-07-26 14:33:57


D

Posted by Swetha Reddy    2013-07-27 04:35:12


Congratulations Sarika Vollala. You are this dose winner. Please send us your mobile details and we will process the recharge asap.

Posted by Merit Campus    2013-07-27 05:03:04


© meritcampus 2019

All Rights Reserved.

Open In App