1(vi)
Typecasting is often necessary when dealing with financial data. Identify the correct syntax to typecast a double to an int using the variables:
int amount; double valueINR
- (a)int amount = valueINR;
- (b)int amount = Integer.parseInt (valueINR);
- (c)int amount = (int) valueINR;
- (d)int amount = int (valueINR);
Show SolutionHide Solution↓
int amount = (int) valueINR;
Reason — The correct syntax to typecast a double to an int in Java is by placing (int) before the double variable, which converts it to an integer by removing its decimal part.