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

How do you do absolute value in java?

985


How do you get the length of a string in java?

1010


What is an abstract class and what is it’s purpose?

963


What is the difference between static (class) method and instance method?

1084


What are annotations in java?

1097


What is the difference between an if statement and a switch statement?

1166


What is a jit compiler?

1136


Can you instantiate the math class in Java?

1093


What is a method vs function?

1047


Explain restrictions for using anonymous inner classes?

1095


What data structures are used to perform recursion?

1054


Can array grow dynamically in java?

988


What is jar?

1125


Difference between start() and run() method of thread class?

1071


Is arraylist sorted in java?

1007