4)
{
int a[]= {10,20,30,40};
for(int i=0;i<=a.length;i++)
{
try {
int b=0;
System.out.println(a[i]/b);
}
catch(ArithmeticException e)
{
System.out.println("invalid number");
}
catch(Exception E)
{
System.out.println(E.getMessage());
}
}
}
}
2)
{
int a=10;
try {
int b=0;
System.out.println(a/b);
}
catch(Exception e)
{
System.out.println("invalid number");
}
}
}
3)
{
int a=10;
try {
int b=5;
System.out.println(a/b);
}
finally
{
System.out.println("invalid");
}
}
}
4)try {
int b=0;
System.out.println(a/b);
}
catch(Exception e)
{
System.out.println("invalid number");
}
finally
{
System.out.println(" Enter valid number");
}
5)It is already handled by the catch block for Exception
6)compilation problem
7)compilation problem
8)compilation problem
9)compilation problem
10)compilation problem
11)compilation problem
12)compilation problem
13)compilation problem
14){
int a[]= {10,20,30,40};
for(int i=0;i<=a.length;i++)
{
try {
int b=0;
System.out.println(a[i]/b);
}
catch(RuntimeException e)
{
System.out.println("invalid number");
}
catch(Exception E)
{
System.out.println(E.getMessage());
}
15)compilation problem
Top comments (0)