Menu
Topics Index
...
`

Return Type


If you need explanation Read this topic

If you need Answer Take test on this topic

Return Type
What will be the output of the following program?
public class SRITCollege {
    public static void main(String[] args) {
        byte y = 1;
        byte x = 1;
        System.out.print(SRITCollege.returm(x, y) + ", ");
        System.out.println(SRITCollege.returm(2, 2));
        System.out.print("Hello + ");
        System.out.print("Hai");
    }
    protected static long returm(byte x, byte y) {
        return (short) (x / y * 2);
    }
}

A. 2, 2
Hello + Hai
B. 2, 4
Hello + Hai
C. Some other output
D. Compilation Error or Runtime Error
Topic: Unknown

If you need explanation Read this topic

If you need Answer Take test on this topic

User comments below. All of them might not be correct.

ans A,first method returns 2, second method returns 2 , cursor goes to next line and prints "Hello + Hai".

Posted by Srikanth Chittela    2014-07-17 13:05:52


Ans is d
because (2,2) can not be applied to9byte,byte)type mismatch

Posted by PaWan Mulchandani    2014-07-17 13:07:49


#pawan

Posted by Shubham Bansal    2014-07-17 14:25:47


ANS D : even though x,y fits in byte by default JVM treats values assigned to x, y as integer literals, to assign integer literals to byte explicit type cast should be done...COMPILER ERROR OCCURS

Posted by BalRam At    2014-07-17 14:55:32


Congratulations PaWan Mulchandani. You are this dose winner. We will send you the link using which you can claim your recharge.

Posted by Merit Campus    2014-07-18 06:43:34


© meritcampus 2019

All Rights Reserved.

Open In App