Menu
Question Index
...

What will be the output of the following program?

class MethodOverloading
{
    public static void main(String[] args)
    {
        int a = 12;
        double b = 13;
        double c = m(a, b);
        double d = m(c, a);
        double e = m(a, (int) d);
        System.out.println("c = " + c + " d = " + d + " e = " + e);
    }

    public static double m(int x, double y)
    {
        return x + y;
    }

    public static double m(double x, double y)
    {
        return x - y;
    }

    public static double m(int x, int y)
    {
        return x % y;
    }
}


c = 25.0 d = 13.0 e = 12.0
c = 25.0 d = 13.0 e = 25.0
c = -1.0 d = -13.0 e = 25.0
Compilation Error

Doubts

Problems

Topic: Method Overloading 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