Computer Science, asked by ashwinilakhan6, 6 months ago

Which of the following are legal lines of Java code? 1

1. int w = (int)888.8;

2. byte x = (byte)100L;

3. long y = (byte)100;

4. byte z = (byte)100L;

A. 1 and 2

B. 2 and 3

C. 3 and 4

D. All statements are correct​

Answers

Answered by arjo89
2

Answer:

D.

Explanation:

Statements (1), (2), (3), and (4) are correct. (1) is correct because when a floating-point number (a double in this case) is cast to an int, it simply loses the digits after the decimal. (2) and (4) are correct because a long can be cast into a byte. If the long is over 127, it loses its most significant (leftmost) bits. (3) actually works, even though a cast is not necessary, because a long can store a byte.

Answered by stuti5496
1

Answer:

option D

Explanation:

All statements are correct

Similar questions