Vidyalelo
Java Programming · Q45

Data Types and Variables

Programming · Java Programming · question 45

Q45

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);

A.
50
B.
10
C.
Compilation Error
Answer
D.
None of these

Answer: Option C

Solution

Answer: Option C
Solution:
lossy conversion from int to short
x = x*5;
       ^
1 error