:: Home Page            
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
Categories >> Software >> Java Related >> Java J2EE >> Core Java


 Core Java interview questions  Core Java Interview Questions (1722)
 Advanced Java interview questions  Advanced Java Interview Questions (331)
 Swing interview questions  Swing Interview Questions (44)
 EJB interview questions  EJB Interview Questions (134)
 Servlets interview questions  Servlets Interview Questions (255)
 Struts interview questions  Struts Interview Questions (196)
 JDBC interview questions  JDBC Interview Questions (187)
 JMS interview questions  JMS Interview Questions (9)
 SunOne interview questions  SunOne Interview Questions (3)
 J2EE interview questions  J2EE Interview Questions (71)
 Weblogic interview questions  Weblogic Interview Questions (147)
 Websphere interview questions  Websphere Interview Questions (14)
 Java Networking interview questions  Java Networking Interview Questions (20)
 Java J2EE AllOther interview questions  Java J2EE AllOther Interview Questions (87)
what is difference between throw and throws in exception?
 Question Submitted By :: Core-Java
I also faced this Question!!     Answer Posted By  
# 1
"throw" is used to handle user-defined exception.
JVM handles the exceptions which are specified by "throws"
Is This Answer Correct ?    258 Yes 50 No
# 2
throws is used to throw an exception from the method
without handling that exception where as 'throw' is used
to throw the exception to catch block and handle it.
Is This Answer Correct ?    121 Yes 77 No
# 3
hi pavitra u r nswer is wrong 
Is This Answer Correct ?    63 Yes 23 No
# 4
In Throws, what ever the exception you are declaring are
handle by JVM. If it is a user defined exception in throws
block, JVM doesn't know when to throw that exception. For
this purpose we use Throw for a certain conditions/logic to
throw these user defined exceptions.

I think the above makes sense.
Is This Answer Correct ?    45 Yes 5 No
Chandra Sekhar
# 5
Method capable of raising an exception but not handling the
same. i.e to say no Try Catch block is implemented in the
Method, to handle the exception.
The callers should create the Try Catch Block to safeguard
against the exception.
If the above is not followed it would result in Compilation

The method that raises the exception also handles the same
in its Catch block.
If unhandled the exception can also be handles by the
Callers Try Catch Block.
Hope this makes sense.
Is This Answer Correct ?    44 Yes 10 No
Anu Mathew
# 6
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
catch(Exception exe)
// catch all the exceptions and provide some meaningful
throw BusinessException("An error occured while
trying to connect to DB");

Is This Answer Correct ?    43 Yes 12 No
# 7
throws keyword is used 2 delegate the responsibility of
exception handling 2 caller method where as throw keyword
used 2 hand over the creted customised excetion object 2
jvm 2 handle the excepion.
Is This Answer Correct ?    33 Yes 7 No
# 8
throw- means user defined exception. we want throw manually
throw the exception.
throws- means jvm going to take all exception.
Is This Answer Correct ?    33 Yes 10 No
# 9
throw is used for to through exception system explicitly,and
throws is u sed for to throws exception means throws
ioexception and servletexception and etc.........
Is This Answer Correct ?    41 Yes 29 No
# 10
throw : throw is used to throw exception by user whenever he
feels to throw exceptions. throw is used to throw
either user defined or runtime exception.
for ex : throw new MyException(), here MyException
is user written exception.
throw new NullPointerException(), here
NullPointerException is RuntimeException.

throws: throws is used by the method to throw exception to
the calling method. And method itself does not able
to handle it so it throws to calling method.
Is This Answer Correct ?    10 Yes 0 No

Other Core Java Interview Questions
  Question Asked @ Answers
What is protected and friendly?   1
what is tempplate pattern RBS 4
Why do inner class cannot have static declaration except static nested class? Wipro 2
what is a static block?   4
what is AWT   3
where u use Abstraction and Interface in real time Sonata 3
Why should we create an object? what is a need of it? Apart from access members of a class i want what is a need of object what does it contain?? In normal class to access any member of thaht class we create object where as for static class we access its members using class name. what is a difference between them... thanks in advance.   1
why ,we are using jsp and html.which one is better? Photon 2
Howmany address lines are required to addressing 1 MB memory? Hexaware 7
What do u mean by wrapper Class? What do u mean by Jvm... How do u change JVM for other OS? Or No need to Change ...? its like tricky EDS 6
what is difference between global methods and local methods?   1
how to make a un-checked exception as a checked exception one.   2
For more Core Java Interview Questions Click Here 

Copyright Policy  |  Terms of Service  |  Articles  |  Site Map  |  RSS Site Map  |  Contact Us
Copyright 2013  All Rights Reserved.   ::