ProgrammingHardProduct-company placement · Java

How many of these statements about Java exceptions are correct? (i) An overriding method may throw any unchecked exception, even if the overridden method declares none. (ii) Catching a checked exception (other than Exception or Throwable) that the try block can never throw is a compile-time error. (iii) A finally block does not run when the try block executes a return statement. (iv) A try block may be followed by finally alone, without any catch.

  1. A. 2
  2. B. 3
  3. C. 4
  4. D. 1

Correct answer: B. 3

(i), (ii) and (iv) are true. (iii) is false: finally runs on return, break, continue and exceptions; only things like System.exit or a JVM crash skip it.

More OOP with C++ and Java questions

Exams that ask this topic