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?

Answers were Sorted based on User's Feedback



what is difference between throw and throws in exception?..

Answer / pasupathi

throw is used to handle user defined Exception where as throws is used ti handle Predefined exceptions

Is This Answer Correct ?    1 Yes 0 No

what is difference between throw and throws in exception?..

Answer / ritesh

Whenever we want to force an exception then we use throw keyword.Moreover throw keyword can also be used to pass a custom message to the exception handling module i.e. the message which we want to be printed.
Whereas when we know that a particular exception may be thrown or to pass a possible exception then we use throws keyword

Is This Answer Correct ?    1 Yes 0 No

what is difference between throw and throws in exception?..

Answer / ramya

throw - used to handle user-defined exception
throws -jvm(java virtual machine) going to take all exception

Is This Answer Correct ?    1 Yes 0 No

what is difference between throw and throws in exception?..

Answer / prabakar

throw:
raised the exception which are occured as a method body.

Throws:
it's the communication bridge between calling function and called function.

Is This Answer Correct ?    1 Yes 0 No

what is difference between throw and throws in exception?..

Answer / basant

) throws keyword gives a method flexibility of throwing an Exception rather than handling it. with throws keyword in method
signature a method suggesting its caller to prepare for Exception declared in throws clause, specially in case of checked Exception and provide sufficient handling of them. On the other hand throw keyword transfer control of execution to caller by throwing an instance of Exception. throw keyword can also be used in place of return as shown in below example:

private static boolean shutdown() {
throw new UnsupportedOperationException("Not yet implemented");
}

as in below method shutdown should return boolean but having throw in place compiler understand that this method will always throw exception .

Is This Answer Correct ?    1 Yes 0 No

what is difference between throw and throws in exception?..

Answer / bhavannarayana ch

To handover an Exception object to the JVM Programatically by using the "throw"

To delegate the responsibility of Exception handling to the caller by using "throws"

Is This Answer Correct ?    1 Yes 0 No

what is difference between throw and throws in exception?..

Answer / naneen kumar h t

please give me answer

Is This Answer Correct ?    1 Yes 0 No

what is difference between throw and throws in exception?..

Answer / ritesh

Throw :- It is possible for your program to throw an
exception explicitly, using the throw statement.

Throws :- If a method is capable of causing an exception
that it does not handle, it must specify this behavior so
that callers of the method can guard themselves against that
exception.

Is This Answer Correct ?    1 Yes 0 No

what is difference between throw and throws in exception?..

Answer / lokesh

throws is used for throwing an exception from a method to
jvm, the jvm should handle it.where us throw is used when
user needs to raise his own exception.

Is This Answer Correct ?    2 Yes 2 No

what is difference between throw and throws in exception?..

Answer / ankur

throw is done manually where as throws is done by jvm

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Core Java Interview Questions

Is string is a data type in java?

0 Answers  


What are possible key words, we can use to declare a class?

2 Answers   Tech Mahindra,


Should a main method be compulsorily declared in all java classes?

0 Answers  


What is threaded programming and when is it used? : Java thread

0 Answers  


Is an empty arraylist null?

0 Answers  


What is static variable and static method?

32 Answers   Accenture, Prolific, Prolifics, TCS, TNH,


What is callablestatement? How you can call stored procedure to pass in parameter?

0 Answers  


Write program to print Hello World and print each character address in that string and print how many times each character is in that string? Ex: H: 0 & 1 e:1 & 1 l :2,3,8 & 3 o:4,6 & 2 w:5 & 1 r: 7 & 1 d 9 & 1

7 Answers   Huawei, IBM,


what is difference between prepare stetement and callable starement with example?

1 Answers   CMC,


What are bind parameters?

0 Answers  


What is constant in programming?

0 Answers  


What is class??

0 Answers   Tech Mahindra,


Categories