Answer:
No ― none of our previous example programs have done this.
InputMismatchException
Here is the example program.
When the user entered "rats", the nextInt() method
threw a InputMismatchException object.
import java.util.* ;
public class Square
{
public static void main ( String[] a )
{
Scanner scan = new Scanner( System.in );
int num ;
System.out.print("Enter an integer: ");
num = scan.nextInt();
System.out.println("The square of " + num + " is " + num*num );
}
}
This program lacks code to deal with this Exception.
So, when nextInt() threw an Exception,
the program threw the Exception to the Java virtual machine.
Then the Java virtual machine caught the Exception,
stopped the program, and printed a trace
of what went wrong.