Q. 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);
}
}

  • (A) 128
  • (B) 0
  • (C) Compilation fails with an error at line 3
  • (D) Compilation fails with an error at line 3 D. Compilation fails with an error at line 4
πŸ’¬ Discuss
βœ… Correct Answer: (C) Compilation fails with an error at line 3
Explanation: byte can only hold up to 127. So compiler complain about possible loss of precision.
Explanation by: Admin
byte can only hold up to 127. So compiler complain about possible loss of precision.

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
110
Total Visits
πŸ“½οΈ
1 y ago
Published
πŸŽ–οΈ
Admin
Publisher
πŸ“ˆ
99%
Success Rate