Question: Question 2 Given: public class Fishing { byte b1 = 4; int i1 = 123456; long L1 = (long)i1; // line A short s2 =
Question 2
Given: public class Fishing { byte b1 = 4; int i1 = 123456; long L1 = (long)i1; // line A short s2 = (short)i1; // line B byte b2 = (byte)i1; // line C int i2 = (int)123.456; // line D byte b3 = b1 + 7; // line E }
Which lines WILL NOT compile? (Choose all that apply.
A. Line A
B. Line B
C. Line C
D. Line D
E. Line E
Answer:
E is correct; compilation of line E fails. When a mathematical operation is performed on any primitives smaller than ints, the result is automatically cast to an integer. A, B, C, and D are all legal primitive casts. (OCA Objective 2.1)
Required :
please explain why answer is correct and why others are not. please explain in detail.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
