Question discussion

What will be output of the following program code?public class Test{ public static void main(String[] a){ short x = 10; x = x*5; System.out…

293539Medium 1 reply 950 views
0
What will be output of the following program code?public class Test{ public static void main(String[] a){ short x = 10; x = x*5; System.out.print(x); } }
  • A50
  • B10
  • CCompilation Error
  • DNone of these
Correct answer: C

Discussion 1

0
CCommunity
Compilation Error

lossy conversion from int to short
x = x*5;
^
1 error