Select chapter



basics (7.papers)
constructors (1.papers)
packages (1.papers)
inheritance (7.papers)
misc (3.papers)
exceptions (5.papers)
threads (4.papers)
overloading (1.papers)
jsp (3.papers)
servlets (9.papers)
jdbc (2.papers)
util (1.papers)
xml (2.papers)
IO stream (3.papers)
Hide

Sponsored Links


  

java exceptions interview questions and answers

1
What is an exception in java?
  1. Any event that occurs at run time which disrupts the normal flow of execution is an Exception.
  2. Any event that occurs at compile time or run time which disrupts the normal flow of execution is an Exception.
  3. only logical errors are called as exceptions.
  4. only syntactical errors are called as exceptions.
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
4
How to handle checked exceptions in java?
  1. we can use Throws to tell that we can't handle it and propagate it to parent functions.
  2. we can use try-catch block to handle exceptions.
  3. we can use either option 1 or option 2 to handle the exceptions.
  4. If an checked exceptions happens, then it is mandatory for that function to handle it by try-catch block only.
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
6
Which of the below doesn't fall under Error category in exceptions?
  1. IOError
  2. IOException
  3. OutOfMemory
  4. StackOverFlowError
Show Answer
Share Facebook gmail Twitter
7
Why programmer need not handle RunTimeExceptions?
  1. Because mostly they are programmatical or logical errors, where programmer has to fix the issue rather than handling or catching it.
  2. Programmer has to catch and handle the RunTimeExceptions also.
  3. Because it is very rare that RunTimeExceptions will occur.
  4. Because mostly RunTimeExceptions occur at compile time.
Show Answer
Share Facebook gmail Twitter
8
Which of the below doesn't fall under RunTimeException category?
  1. IndexOutOfBoundsException
  2. NullPointerException
  3. ArithmeticException
  4. FileNotFoundExceptoin
Show Answer
Share Facebook gmail Twitter
9
What does a function will do when an exception occurs at run time, in that function?
  1. That function will throw that exception to java run time system
  2. that function will throw that exception to previous function
  3. that function will handle that exception
  4. all are true.
Show Answer
Share Facebook gmail Twitter
10
What does an exception object will contain?
  1. An exception object will contain only type of the error.
  2. An exception object will contain the information about the program when that exception occurred. Information like what is the function name, stack trace, line number, and variable values when program got exception.
  3. Exception object will contain both option 1 and 2.
  4. Exception object will not contain any thing important.
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
12
What type of exceptions programmer has to handle in java?
  1. checked
  2. unchecked
  3. both checked and unchecked
  4. no need to handle any exception as JRE will handle it.
Show Answer
Share Facebook gmail Twitter
13
How many catch blocks should a try block have?
  1. It should have minimum one catch block.
  2. it should have only one catch block.
  3. a try block with out catch block is possible, in case if it is having finally block.
  4. a try block should have both catch and finally attached to it.
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
15
"No need to handle unchecked exceptions." Does it mean programmer can ignore all kinds of un checked exceptions?
  1. Yes, programmer can ignore un checked exceptions as it won't give any compile time error.
  2. Programmer should not handle it with try-catch block, rather programmer has to debug and fix un-checked exceptions (errors), esp runtimeExceptions.
  3. programmer has to handle un checked exceptions with try-catch block or throws clause else compiler will throw error.
  4. none
Show Answer
Share Facebook gmail Twitter
16
Lets assume that main() has called fun1(), which calls fun2(), which calls fun3(). And assume that fun3() has thrown some exception object to java run time system, now in which order java run time system will search for the exception handler?
  1. it searches in below order. main, fun1, fun2, fun3
  2. it searches in below order. fun3, fun2, fun1, main
  3. it searches in the below order fun2, fun1, main
  4. it searches only fun3.
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
18
What does java run time system will do, when some functions hands over some exception object to it?
  1. java run time system will force close your application.
  2. Java run time system will search for the code which can handle that exception. (i.e it searches for catch block which can handle that exception)
  3. java run time system will give that exception object to JVM to find the exception handler in the program
  4. none of the above
Show Answer
Share Facebook gmail Twitter
19
Why programmer don't need to handle Errors in Un-checked exceptions category?
  1. because they are logical errors.
  2. Because they are mostly hardware problems, like hard disk crash, which is not in the hands of programmer.
  3. Because it is syntactical error, which we have to fix at compilation time.
  4. Programmer has to handle Errors.
Show Answer
Share Facebook gmail Twitter
20
How to handle un-checked exceptions?
  1. we can use Throws to tell that we can't handle it and propagate it to parent functions.
  2. we can use try-catch block to handle exceptions.
  3. No need to handle, but you have to fix that error in case of RunTimeException. You can't do any thing with hard ware errors.
  4. none
Show Answer
Share Facebook gmail Twitter
Read more papers :