Menu
Topics Index
...
`

MultilevelInheritance2753


If you need explanation Read this topic

If you need Answer Take test on this topic

MultilevelInheritance2753
What will be the output of following program?
class Producer
{
    void story()
    {
        System.out.println("No story");
    
    }
}    
class Director extends Producer
{
    void story()
    {
        super.story();
        System.out.println("With story");
    }
}
class Hero extends Director
{
    void story()
    {
        super.story();
        System.out.println("Good Movie");
    }    

}
public class Movie
{
    public static void main(String args[])
    {
        Hero hero=new Hero();
        hero.story();
    }
}

A. Good Movie
B. With story
Good Movie
C. No story
With story
Good Movie
D. Compilation Error or Runtime Error
Topic: Super Keyword In Java To Call Super Class Constructor

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:..we are calling hero.story() means it wl cal method which is in hero class there we are calling super.storty() means it wl cal in director class n thr super.story() means Producer class

Posted by Uday Kumar    2014-06-12 12:48:29


Answer is [C] in every story() function it is calling its super class story function before printing text in its body

Posted by Ashok Kumar Paritala    2014-06-12 12:50:34


Congratulations Uday Kumar. You are this dose winner. We will send you the link using which you can claim your recharge.

Posted by Merit Campus    2014-06-13 04:09:12


© meritcampus 2019

All Rights Reserved.

Open In App