Menu
Question Index
...

What will be the output of the following program?

class MethodOverloading
{
    public static void main(String s[])
    {
        int i = 8;
        print(i);
        print();
        int j = 9;
        print(j);
    }

    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 i");
    }

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


Called print with int parameter j
Called print with no parameters
Called print with int parameter i
Called print with int parameter i
Called print with no parameters
Called print with int parameter j
Compilation Error
Runtime 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