Java OCA OCP Practice Question 139

Question

In the following code, what are the possible types for variable result?

(Choose the most complete true answer.)

1. byte b = 11; 
2. short s = 13; 
3. result = b * ++s; 
  • A. byte, short, int, long, float, double
  • B. boolean, byte, short, char, int, long, float, double
  • C. byte, short, char, int, long, float, double
  • D. byte, short, char
  • E. int, long, float, double


E.

Note

The result of the calculation on line 2 is an int.

Because all arithmetic results are ints or wider.

An int can be assigned to an int, long, float, or double.




PreviousNext

Related