/* Example showing overflow in Java. Written by: Dan Stearns Fall 2001 Questions: 1. What does a CPU do when an overflow occurs? 2. What does the Java Virtual Machine do when an overflow occurs? 3. How should the programmer handle a possible overflow? */ import java.io.*; public class overflow { public static void main (String args[]) { int c = 2000000000; int d = 2000000000; int e = c + d; System.out.println("sum = " + e); // do divide by 0 for 315 show and tell e = c / 0; } } /* Output sum = -294967296 */