Pod Project: Casting About

Put your answers in a plain text document. If you don't have a text editor Atom is great for this purpose. Get it. You have option of putting this in HTML format.

One submission per pod.

Casting Games Consider this table. Put "Y" in the box if you can cast from one type to the other an explicit cast, "M(aybe)" if you you must put an explicit cast, and NO otherwise.

Here are some examples. I posted the results into the table. Notice that there is no type change from byte to byte so it got a Y.

jshell> int x = 5.0;
|  Error:
|  incompatible types: possible lossy conversion from double to int
|  int x = 5.0;
|          

But you can do this with an explicit cast.

jshell> int x = (int)(5.0);
x ==> 5
jshell> (boolean) 1
|  Error:
|  incompatible types: int cannot be converted to boolean
|  (boolean) 1
|   
TObyteshortintlongfloatdouble booleanchar
byte Y
short
int YN
long
float
double M
boolean
char

Can you, based on observations, distill this down to a few simple rules?