Menu
Topics Index
...
`

Methods


If you need explanation Read this topic

If you need Answer Take test on this topic

Methods
What is the widest valid returnType for methodA in LINE K?
public class ReturnIt {
    returnType methodA(byte x, double y) //LINE K
    {
        return (long)x / y * 2;
    }
}

A. int
B. byte
C. long
D. double
Topic: Java Methods - Parameter Passing And Scope

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.

Option D  as x is converted to long and then divided with a double values whose output is a double value so widest possible returntype is double as it is only datatype among the options which could retain digits after the decimal points  as there is no typecastng involved answer must be D .

Posted by Ratan Dhoka    2013-06-20 03:52:42


Answer is option D

Posted by Satya Achanta    2013-06-20 07:22:43


Congratulations Ratan Dhoka. You are this dose winner. Please send us your mobile details and we will process the recharge asap.

Posted by Merit Campus    2013-06-20 08:39:16


© meritcampus 2019

All Rights Reserved.

Open In App