?
What will be the output for the below code?
What will be the output for the below code?
public class Test{
public static void main(String[] args){
byte i = 128;
System.out.println(i);
}
}
public class Test{
public static void main(String[] args){
byte i = 128;
System.out.println(i);
}
}
Answer & Solution
Correct Answer:
Option
C
byte can only hold up to 127. So compiler complain about possible loss of precision.
static byte MAX_VALUE − This is constant holding the maximum value a byte can have, 27-1.
static byte MIN_VALUE − This is constant holding the minimum value a byte can have, -27.
static byte MAX_VALUE − This is constant holding the maximum value a byte can have, 27-1.
static byte MIN_VALUE − This is constant holding the minimum value a byte can have, -27.
Join the Discussion
Login to post a comment or share your explanation.
Loginbyte i = (byte)128;
system.out println(b);
output : -128
plz.... reply