Menu
Question Index
...

What will be the output of the following program?

public class TrzIt {
    public static void book(short a) {
        System.out.print("short ");
    }
    public static void book(Short a) {
        System.out.print("SHORT ");
    }
    public static void book(Long a) {
        System.out.print("LONG ");
    }
    public static void main(String[] args) {
        Short shortRoom = 1;
        int intRoom = 2;
        book(shortRoom);
        book((short) intRoom);
    }
}


SHORT SHORT
short short
short SHORT
SHORT short
Some other output
Compilation Error or 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