🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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);
    }
}
  1. A.10
  2. B.9
  3. C.9.99
  4. 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 →