Menu
Topics Index
...
`

Creating abstract classes


If you need explanation Read this topic

If you need Answer Take test on this topic

Creating abstract classes
What is the output of the program?
public abstract class DemoOnAbstractClasses {
    public int getValue() {
        return 28;
    }
    public abstract class DemoClass {

        public int getValue() {
            return 33;
        }
    }
    public static void main(String args[]) {
        DemoOnAbstractClasses objectOfAbstractClasses = new DemoOnAbstractClasses() {
            public int getValue() {
                return 45;
            }
        };
        DemoOnAbstractClasses.DemoClass demoClass = objectOfAbstractClasses.new DemoClass() {
            public int getValue() {
                return 66;
            }
        };
    System.out.println(demoClass.getValue() + "," + objectOfAbstractClasses.getValue());
    }
}

A. 66, 45
B. Compilation Error due to  class created in another class
C. 45, 33
D. Runtime error
E. Compilation Error due to other reasons
Topic: Nested And Inner Classes

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 e.demoonabstrctclass. Democlass  democlas cant instantiate.
enum identifier needed..syntax err

Posted by NagaRaj Nataraj    2014-06-19 08:58:50


Ans is a..wen caling with demoClass refernce 66 wil returnd n wen calling with objectof abstrctclass obj 45 wil return

Posted by Uday Kumar    2014-06-19 12:25:08


No winner for this dose. Correct option is 'A' :(. Uday Kumar was already won in this week.

Posted by Merit Campus    2014-06-20 04:34:19


I won 10rs Qstion not 20rs..?

Posted by Uday Kumar    2014-06-20 10:21:24


Uday Kumar according to the rules, for complex question you can win as many times, but for simple and medium you can only win once :-)

Posted by Merit Campus    2014-06-20 14:52:46


© meritcampus 2019

All Rights Reserved.

Open In App