Menu
Question Index
...

What will be the output of the following program?

public class Hyderabad1 {
    public static void main(String args[])
    {
            ChandaNagar obj1 = new ChandaNagar();
            System.out.print(obj1.operation(2, 3, 4));
            Hyderabad obj2 = new Hyderabad();
            System.out.print(" "+obj2.operation(2, 3, 4));
            System.out.print(" "+obj1.operation(2, 3));
            System.out.print(" "+obj1.operation(2, 3, 4, 5));
        
    }
}
class Hyderabad
{
    public int operation(int x, int y)
    {
        return x + y;
    }
    public  int operation(int x, int y, int z)
    {
        return x + y + z;
    }
    
}
class ChandaNagar extends Hyderabad
{
    public  int operation(int x, int y, int z)
    {
        return x * y * z;
    }
    public  int operation(int w, int x, int y, int z)
    {
        return w + x + y + z;
    }
}


9 9 5 14
24 9 5 14
Compilation Error
Runtime Error

Doubts

Problems

Topic: Method Overloading Vs Method Overriding

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App