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

1) float f -5/2 System.out.println (f)i System.out.printin (\'G\'+2) 2) int x =

ID: 3717836 • Letter: 1

Question

1) float f -5/2 System.out.println (f)i System.out.printin ('G'+2) 2) int x = 4; int y = 2; boolean z--x-4 11 x++ * y--"-8; System.out.println (x) System.out.printin (y)i System.out.printin (z) 3) public class Operations private static int val://initialized to be o public static void main (Stringl args) int result- (one 0+to )) (threeO-five 0)+four System.out-printin (result) public static int one O System.out-printin("one")val+xeturn val: public static int twoO System.out.printin("two"): val++ireturn val: public static int three O System.out printin ("three") val++ireturn val: public static int fourSystem.out.printin("four") val+ireturn vali) public static int fiveSystem.out.println("five") val++ireturn val:)

Explanation / Answer

1) f is 2.0 and 'G'+2 is 73. we get f as 2.0 though it was 5 divided by 2 because the operands were integer and hence we get 2.0 as output. if we defined 5 and 2 as floating point we could've got 2.5. In java, a char occupies 16 bit in UTF-16 encoding.G's unicode is U+0047, in binary 0000 0000 0100 1111.When you sum a char and an int(32 bit), the char will be promoted to int by inserting 0 into the begin of its binary representation. So 0000 0000 0100 1111 is converted to 0000 0000 0000 0000 0000 0000 0100 1111(in decimal, 71).That's why you get 73.

2) x is 4 as it gets pre decremented first then gets post incremented hence it remains as 4. y is 1 as it gets post decremented , Z is false as both are false statements and hence since its boolean operation of OR it results in false.

3)The outputs are:

one

two

three

four

five

2(result is 2 as per the operation performed from functions one(), two(), three(), four(), five())