Program for Exception Handling in Java using try and catch blocks
1. Open the notepad file.
2. Write the code given below in the file.
import java.util.Scanner;
class Excep
{
public static void main(String args[])
{
int div,a,b;
Scanner input= new Scanner(System.in);
System.out.println("Enter 1st Number");
a=input.nextInt();
System.out.println("Enter 2nd Number");
b=input.nextInt();
try
{
div=a/b;
1. Open the notepad file.
2. Write the code given below in the file.
import java.util.Scanner;
class Excep
{
public static void main(String args[])
{
int div,a,b;
Scanner input= new Scanner(System.in);
System.out.println("Enter 1st Number");
a=input.nextInt();
System.out.println("Enter 2nd Number");
b=input.nextInt();
try
{
div=a/b;