Core Java - Interview Questions and Answers for 'Throw' | Search Interview Question - javasearch.buggybread.com
Javasearch.buggybread.com

Search Interview Questions


 More than 3000 questions in repository.
 There are more than 900 unanswered questions.
Click here and help us by providing the answer.
 Have a video suggestion.
Click Correct / Improve and please let us know.
Label / Company      Label / Company / Text

   



Core Java - Interview Questions and Answers for 'Throw' - 6 question(s) found - Order By Newest

 Q1. What things should be kept in mind while creating your own exceptions in Java?Core Java
Ans. All exceptions must be a child of Throwable.

If you want to write a checked exception that is automatically enforced by the Handle or Declare Rule, you need to extend the Exception class.

You want to write a runtime exception, you need to extend the RuntimeException class.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   exceptions   exception handling   user defined exceptions   throwable   architecture   library development   technical architect   technical lead


Very Frequently asked.
 Q2. Explain throw, throws , try and catch in Java ?Core Java
Ans. throw is used to re throw an exception.throws is used to declare that the method throws the respective exceptions.try block is used to identify if the respective block has thrown any exception.catch is used to catch the exception that has been thrown by the respective try block.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   exception handling   throw   throws   try   catch     Asked in 5 Companies      basic        frequent


 Q3. What is exception propogation ?Core Java
Ans. Passing the exception object to the calling method.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   exceptions   exception handling   throw


 Q4. Difference between throw and throws ?Core Java
Ans. throw is used to explicitly throw an exception especially custom exceptions, whereas throws is used to declare that the method can throw an exception.

We cannot throw multiple exceptions using throw statement but we can declare that a method can throw multiple exceptions using throws and comma separator.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   exceptions   exception handling   throw   throws   difference between   basic interview question      basic        frequent

Try 1 Question(s) Test


 Q5. What is the purpose of re throwing the exception when we can provide the handling at the first catch itself ?Core Java
Ans. Sometimes the calls move across layers of classes and functions and hence each layer needs to perform some function like cleaning if something goes wrong deep inside.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     exceptions  exceptions handling  rethrowing exception


 Q6. What is Throwable ?Core Java
Ans. Throwable in java is a class that is the superclass of all exceptions and errors which may occurs in java program.It extends obcect class.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     exception handling   throwable     Asked in 1 Companies      basic


 Q7. In Case a method is declared to throw an exception , We can only use a call to that method if ...Core Java
a. We use the call within try block and catch the exception
b. We declare that the method is expected to throw the exception using throws
c. Both 1 and 2
d. Either 1 or 2

Ans.d. Either 1 or 2

 Q8. Which of the following is true ?Core Java
a. throw and throws are used to throw an exception
b. throw is used to throw an exception whereas throws is a declaration that the method can throw the exception
c. throws is used to throw an exception whereas throw is a declaration that the method can throw the exception
d. throw and throws are used to declare that an exception can be thrown by the method

Ans.b. throw is used to throw an exception whereas throws is a declaration that the method can throw the exception

 Q9. throws is a declaration that the ..... is expected to throw an exception ?Core Java
a. Variable
b. Method
c. Class
d. Interface

Ans.b. Method


Help us and Others Improve. Please let us know the questions asked in any of your previous interview.

Any input from you will be highly appreciated and It will unlock the application for 10 more requests.

Company Name:
Questions Asked: