🎙 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 1 of 10

What does this print? (code)

What does this print?

public class Main {
    public static void main(String[] args) {
        System.out.println(10 / 4);
    }
}
  1. A.2.5
  2. B.2
  3. C.3
  4. D.2.0
Answer & explanation

Correct answer: 2

Both are ints, so Java does integer division and drops the .5.

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 →