Menu
Question Index
...

What will be the output of the following program?

class MethodOverloading
{
    public static void main(String s[])
    {
        print();
        print(8);
        print(20 < 10);
    }

    public static void print()
    {
        System.out.println("Called print with no parameters");
    }

    public static void print(int i)
    {
        System.out.println("Called print with int parameter");
    }

    public static void print(boolean b)
    {
        System.out.println("Called print with boolean parameter");
    }
}


Called print with no parameters
Called print with int parameter
Called print with boolean parameter
Compilation Error - Since we can not have same method name print for 3 methods
Compilation Error - Since we need to have a different return type for each method
Called print with no parameters
Called print with int parameter

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