About Question enthuware.ocajp.i.v8.2.1440 :
Posted: Sun Apr 12, 2015 10:42 am
The explanation given with this question, belongs to another question:
If you just consider the method getSwitch, any of int long float or double will do. But the return value is used in the switch statement later on. A switch condition cannot accept float, long, double, or boolean. So only int is valid. The return type cannot be byte, short, or char because the expression x - 20/x + x*x; returns an int.
If you just consider the method getSwitch, any of int long float or double will do. But the return value is used in the switch statement later on. A switch condition cannot accept float, long, double, or boolean. So only int is valid. The return type cannot be byte, short, or char because the expression x - 20/x + x*x; returns an int.