128k views
1 vote
Will the following statement sequence compile? If not which line causes the compile error? The line numbers are just for reference. ____________________ double i; int j = 2; i = j; j = i; ___________ Select one:

a. No, line 4
b. No, line 3
c. Yes
d. No, line 1
e. No, line 2

1 Answer

5 votes

Final answer:

The statement sequence will not compile due to a type mismatch error on line 4. Casting the double value to an int or declaring i as an int would fix the error.

Step-by-step explanation:

The statement sequence will not compile due to a type mismatch error on line 4. In Java, you cannot assign a double value to an int variable without explicit casting. To fix the error, you can either cast the double value to an int or declare the i variable as an int instead of double.

User Lalitya
by
7.0k points