← 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);
}
}
- A.10000000000
- B.1410065408
- C.Compile error
- 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 →