Java help - plz

gar598

Golden Member
Mar 25, 2001
1,915
1
0
Are the following conversions involving casting allowed? If so, find the converted result.
char c = 'A';
i = (int)c;

YES

i = 65

boolean b = true;
i = (int)b;

YES

i = 1

double d = 1000.34;
int i = (int)d;

NOT ALLOWED

int i = 1000;
char c = (char)i;

int i = 1000;
boolean b = (boolean)i;

NOT ALLOWED
 

notfred

Lifer
Feb 12, 2001
38,241
4
0
my compiler fails when casting a boolean as an int, and when casting an int as a boolean. Works fine with all other cases.