Integer group variables addition output
What will be the output of the following program?
class IntegerGroupAddition
{
public static void main(String args[])
{
long l = 30;
int i = 50;
short s = 60;
byte b = 70;
int sum = l + i + s + b;
System.out.println("Sum = " + sum);
}
}
A.
|
Sum = 210
|
B.
|
Sum = 128
|
C.
|
Sum = 127
|
D.
|
Program does not compile.
|
Topic:
Type Casting In Java
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:D we are adding long to int value, long value cannot be converted into int value
Posted by Indrasena Reddy 2014-08-11 12:53:46
D..bcz loss of precission occurs on adding s.
Posted by Shabaaz Shaikz 2014-08-11 12:56:59
d
Posted by Zeg Abder 2014-08-11 13:57:48
Congratulations Indrasena Reddy. You are this dose winner. We will send you the link using which you can claim your recharge.
Posted by Merit Campus 2014-08-12 04:09:52