Java Exception Handling Interview Questions and Answers

Java Exception Handling Interview Questions

1) How many types of errors are there in Java?

A) There are two types of errors are there in Java:
1) Compilation error.
2) Run-time error.

2) What is a compilation Error?

A) Any error that occurs at the time of compilation could be called as Compilation Error.

3) What is Run-time Error?

A) Any Error that occurs at the time of execution of the program could be called as Run-time Error.

4) What is logical Error?

A) Any wrong logic which leads for the wrong outputs could be called as a logical Error.

5) What is Abnormal Termination?

A) Terminating any program in the middle of its execution and controlling coming out of the application (or) program without executing the last statement of the main method is known as Abnormal Termination.

6) What is Exception?

A) Exceptions are the objects representing logical Errors and Run-time Errors.

7) What is Exception handling?

A) The concept of identifying an exception and catching that exception and assigning that exception to the reference of the corresponding exception class is known as Exception Handling.

8) What is Hard coding?

A) The concept of using values directly is called Hard coding.

9) What are two types of Logical Errors?

A) There are two types of Logical Errors. They are:
1) Simple Logical Errors.
2) Serious Logical Errors.

10) Explain simple logical Errors?

A) All the Logical Errors which could be neglect by the JVM are called Simple Logical Errors.

11) Explain about Serious Logical Errors?

A) All the logical Errors (or) the run-time errors which could not be neglect by the JVM is Known as Serious Logical Errors.

12) How many types Java Exceptions are divided?

A) All the Exceptions are divided into two types. They are:
1) Checked Exceptions.
2) Un-checked Exceptions.

13) Explain about Checked Exceptions?

A) All the Exceptions which are not the sub-class of Run-time Exceptions are known as Checked Exceptions.

14) Explain about Un-Checked Exceptions?

A) All the Exceptions which are the sub-class of Run-time Exceptions are known as Un-Checked Exceptions.

 15) What is the difference between “Throws” and “Throw”?

A) Using throws we can only Explicitly provide the information about the unhandled Exceptions to the Java compiler and JVM and end user. But whereas using throw we would be Explicitly raising an Exception representing the user-defined Run-time errors.

16) Explain about Try Keyword?

A) Try: Try establishes a block to write a code that causes exceptions and its related statements. Exception causing statement must be placed in a try block to be handled and catch that exception for stopping abnormal termination.

17) Explain about Catch Keyword?

A) The catch block is used to catch exceptions those are thrown from its corresponding try block. It has logic to take necessary action on that caught exception.

18) Explain about Final block?

A) Final establishes a block that definitely executes statements placed in it. Statements which are placed in this block are always executed irrespective of the way the control is coming out from the try block either by completing normally, by return statements or by throwing an exception, by catching or not catching.

19) What is Exception propagation?

A) The process of sending exception from called method to calling method is called as Exception propagation.

20) Explain the uses of Throws Keyword?

A) 1) Using throws keyword we provide the complete information about the unhandled Exceptions to the user and to the Java compiler.
2) Using throws keyword we can avoid try & catch blocks with respect to the statements proven to generate Checked Exceptions in a method.

23) Explain about Finally?

A) Finally, blocks can be executed compulsory with irrespective of Exceptions.

24) Explain the uses of the Finally block?

A) The two uses of Finally block are:
1) Using Finally block we can maintain proper separation between the statements belonging to the try, catch and the statements belonging to the function.
2) Using Finally blocks we can avoid catch blocks.

25) When it is mandatory to call a method inside try & catch blocks?

Our Services

Search This Blog

  • ()
Powered by Blogger.

C Variables and Types of Variables in C

C variable is a data name that may be used to store a data value. The value of the C variable may get change in the program and it can be r...