|
No. |
Java Question |
Answer/Output |
Explanation |
|
1 |
static final transient int a = 20; |
No Error |
- |
|
2 |
int i = -76;
final int j = i; |
No Error |
- |
|
3 |
int i = -76;
final int j = i;
char ch = j; |
Compile Time Error |
Here cast is required because final value of j is not determinable. So, it should
be like char ch = (char)j; |
|
4 |
final int a = 200;
byte b = (byte) a; |
-56 |
Here final value of a is not in range. So, cast is required. If a = 128, then output
might be -128. |
|
5 |
final int x = 23;
byte a;
short j = a = x;
SOP(j); |
23 |
- |