Managing Errors and Exception Questions and Answers

Read tutorials from Managing Errors and Exception


Question List:

1. If a NoClassDefFoundError occurs when you run a program, what is the cause of the error?

2. If a NoSuchMethodError occurs when you run a program, what is the cause of the error?

3. What are syntax errors (compile errors), runtime errors, and logic errors?

4. Give examples of syntax errors, runtime errors, and logic errors.

5. If you forget to put a closing quotation mark on a string, what kind error will be raised?

6. If your program needs to read integers, but the user entered strings, an error wouldoccur when running this program. What kind of error is this?

7. Suppose you write a program for computing the perimeter of a rectangle and you mistakenly write your program so that it computes the area of a rectangle. What kind of error is this?

8. Identify and fix the errors in the following code:

9. The following program is wrong. Reorder the lines so that the program displays morning followed by afternoon .

10. Difference between throw and throws?

11. What is NullPointerException?

12. What are the ways in which a thread can enter the waiting state?

13. Does it matter in what order catch statements for FileNotFoundException and IOException are written?

14. When ArithmeticException is thrown?

15. What class of exceptions are generated by the Java run-time system?

16. Under what conditions is an object's finalize() method invoked by the garbage collector?

17. Which arithmetic operations can result in the throwing of an ArithmeticException?

18. Variable of the boolean type is automatically initialized as?

19. Can try statements be nested?

20. What is the difference between error and an exception?

21. How does a try statement determine which catch clause should be used to handle an exception?

22. What do you mean by try-catch block?

23. Write general syntax of try-catch block