Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

When try and catch block is used ?

Answer Posted / anandh

Try and Catch block is used for Exception handling..
Try block is used for monitor the errors and using catch
block we can shows to users what type of Exception occurred
in our program ...see the following Example code it can be
useful..


class ExceptionExample
{
public static void main(String args[])
{
int d, a;
try
{
d = 0;
a = 42 / d;
System.out.println("This will not be printed.");
}
catch (ArithmeticException e)
{
System.out.println("Division by zero.");// Here shows
Exception to user
}

}
}

Is This Answer Correct ?    1 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a bubble sort in java?

901


Explain thread in java?

1097


What are java methods?

1039


What exactly is java?

887


What are use cases?

906


How to perform quicksort in java?

1040


Can we create object of inner class in java?

884


What are the advantages of exception handling?

1012


What is the difference between a local variable and an instance variable?

1021


Does java linked list allow duplicates?

917


Convert Binary tree to linked list.

1014


Is Constructor possible in abstract class in java ?

987


Which language is java?

924


What is array in java?

945


Can we create our own wrapper class in java?

913