KnowledgeBoat Logo
|

Computer Applications

Which of the following statement is an example for explicit typecasting?

  1. int amount = 45;
  2. int amount = 24*24;;
  3. int amount = Integer.parseInt("45")
  4. int amount = (int)45.75;

Values & Data Types Java

2 Likes

Answer

int amount = (int)45.75;

Reason — Explicit typecasting is when we manually convert one data type to another by specifying the type in parentheses. Here, (int)45.75 converts the double value 45.75 to an int by removing the decimal part.

Answered By

2 Likes


Related Questions