← Quiz: Java Data Types: all 10 questions
Quiz: Java Data Types · Question 2 of 10
What does this print? (code)
What does this print?
public class Main {
public static void main(String[] args) {
double d = 9.99;
System.out.println((int) d);
}
}
- A.10
- B.9
- C.9.99
- D.Error
Answer & explanation
Correct answer: 9
Casting to int cuts off the decimal part; it does not round.
Can you get the rest right without peeking?
Take the timed Quiz: Java Data Types quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →