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 condition in java?

997


In a container there are 5 components. I want to display all the component names, how will you do that?

2186


What are the main concepts of oops in java?

1732


What are the Main functions of Java?

1088


What are the different types of garbage collectors in java?

1128


What is another word for methodology?

1013


What is anagram number?

942


Can an interface extend another interface?

1051


How do you compare characters in java?

983


What is diamond operator in java?

944


What are heap memory and stack memory and what are memory tables.

982


What are loops in java?

1256


How many characters is 2 bytes?

984


Is class is a data type?

1072


What is functional interface in java example?

981