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

What does this print? (code)

What does this print?

public class Main {
    public static void main(String[] args) {
        long total = 100000 * 100000;
        System.out.println(total);
    }
}
  1. A.10000000000
  2. B.1410065408
  3. C.Compile error
  4. D.-1
Answer & explanation

Correct answer: 1410065408

Both numbers are int, so the multiplication is done in int and overflows BEFORE the result is stored in long. Write 100000L * 100000 to get 10000000000.

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 →