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...

what is difference between throw and throws in exception?

Answer Posted / raj

throws --> throws declare that it throws the exception to
the calling method.

throw --> it is surrounded by the try catch block actually
it does the work, of throwing the exception.

For Example:

public void testMethod() throws BusinessException
{
try
{
}
catch(Exception exe)
{
// catch all the exceptions and provide some meaningful
message
throw BusinessException("An error occured while
trying to connect to DB");
}

}

Is This Answer Correct ?    43 Yes 13 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

List out benefits of object oriented programming language?

895


What is the difference between the size and capacity of a vector?

1038


Can static method access instance variables ?

1136


What is difference between word and integer?

1075


What is the full meaning of java?

1042


Why convert an applet to an application?

1102


How can we run a java program without making any object?

1044


What is the use of using enum to declare a constant?

1024


What is t in parametric equations?

991


How will you compute size of a structure?

1176


What is sizeof in java?

1105


What is void in java?

1075


What is the difference between declaration and definition in java?

1072


Explain covariant method overriding in java.

1101


How many bits is a char?

981