I will try and give this a shot.
1. You are mixing syntax with your assignment. The '\0' signifies octal notation. Therefore, '\0x0001' will try and interpret x0001 as an octal value (which is not a valid octal value). To make is hexadecimal you leave off the single quotes (i.e., 0x0001).
2. According to the Java Spec:
15.7.1 Evaluate Left-Hand Operand First
The left-hand operand of a binary operator appears to be fully evaluated before any part of the right-hand operand is evaluated.
Using that logic we can easily see that the expression will work out to:
x = (a = true) || (b = true) && (c = true);
x = true || (b = true) && (c = true);
from this point on the result of x is given because ORing true against anything else will result as true. Therefore, we don't need to perform any more steps. Since we have evaluated the a = true
assignment fully then a will be true while b and c will still remain false.
3. In the m1 method, the compiler actually replaces the return c
line with return '\u0001'
. Therefore the return type can be shown as byte because the unicode leteral can fit into a byte. In the method m3, you are trying to convert a character into a byte which can't be done without casting.