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
- int amount = valueINR;
- int amount = Integer.parseInt (valueINR);
- int amount = (int) valueINR;
- 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
The Math method which returns int value is:
- round()
- cbrt()
- ceil()
- random()
What is the output of the following statement:
“MONOPOLY”.lastIndexOf(‘O’);- 1
- 3
- 2
- 5
What is the output of the code snippet given below?
int lives = 5; System.out.print(lives--); System.out.print(lives);- 4 3
- 5 4
- 5 3
- 4 4
What will be the output of the following statement?
String s = "JavaProgramming"; System.out.println(s.substring(4, 11).toUpperCase());- Programm
- PROGRAMM
- PROGRAM
- program