KnowledgeBoat Logo
|

Computer Applications

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

  1. int amount = valueINR;
  2. int amount = Integer.parseInt (valueINR);
  3. int amount = (int) valueINR;
  4. int amount = int (valueINR);

Values & Data Types Java

7 Likes

Answer

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.

Answered By

3 Likes


Related Questions