3. Operators and Assignments

3.1 (a)

A value of type char can be assigned to a variable of type int. An implicit widening conversion will convert the value to an int.

3.2 (d)

An assignment statement is an expression statement. The value of the expression statement is the value of the expression on the right hand side. Since the assignment operator is right associative, the statement a = b = c = 20 is evaluated as follows: (a = (b = (c = 20))). This results in the value 20 being assigned to variable c, then the same value being assigned to variable b and finally to variable a. The program will compile correctly and display 20 when run.

3.3 (c)

Strings are objects. The variables a, b, and c are references that can denote such objects. Assigning to ...

Get Programmer's Guide to Java™ Certification, A: A Comprehensive Primer, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.