Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

ethat have been assigned initial 6. Given variables of type IE and j of type dou

ID: 3912458 • Letter: E

Question

ethat have been assigned initial 6. Given variables of type IE and j of type dousis is valid or invalid. Valid is defivalte as determine whether each of the following statements producing no errors at compilation or runtime. (2 points each) (c) System.out.printin("result -1); Vi) i521; Divar (e) j; Math. pow(2.0, 3.0); v.w 7. Evaluate each of the following valid expressions. (4 points each) (a) 55 % 4 (c) 55.0 4 13.25 (d) 15/5/2 15 (e) 60.0e-14e+1 9ys978 (0 2 f02) 2) -2 (-2) 28 8. What would be the output of the following code segment? Assume apple and ban been declared as integer variables. (6 points) ana have apple -3; apple- banana 1 apple; apple apple * apple; Syst em.out.printin (banana): System.out.printin (apple); 16 -4)-S 5, 16

Explanation / Answer

6) a) Invalid (ArithmeticException: / by zero) b) Valid. e) Math.pow returns a double value which when stored in integer may have compilation problems You're correct about the rest.

You're correct about what you've done in Q7 and 8 too. Well done.

in 11) You've been correct about everything. The last print question will print the arithmetic of (d % 10) and since the value of d is 2 it will print 2.