Exception handling Quiz in Java

Exceptions Java - MCQ - 50 Multiple choice questions in 2 sets



This Quiz consists of Exception's 150 Multiple choice questions in 6 sets - Java Exceptions quiz - MCQ

Contents of page >

Exceptions Java - MCQ set 1 (25 questions, 50 marks)
Exceptions Java - MCQ set 2 (25 questions, 50 marks)







Note : Each set consists of 25 questions
Each set consists of 5 EASY level difficulty questions 1 mark each.         1 * 5 = 5 marks
Each set consists of 15 MEDIUM level difficulty questions 2 mark each. 2 * 15 = 30 marks
Each set consists of 5 HARD level difficulty questions 3 mark each.       3 * 5 = 15 marks
So, Each set is TOTAL of 50 marks
This quiz have been designed to check beginners and experienced Java developers skills. Scoring below 15 marks means POOR : You are Java Beginner and need to work very hard. Scoring 15-30 marks means AVERAGE : You know Java basics, but you need more practice. Scoring 31-45 marks means GOOD : You have good Java knowledge. Scoring above 45 marks means EXCELLENT : You have outstanding java knowledge.




Exceptions Java - MCQ set 1 (25 questions, 50 marks)



    Q1 - Q5, 5 EASY level difficulty questions 1 mark each. 1 * 5 = 5 marks

  1. Exception is a class/interface/abstract class/other?

  2. a.Class
    b.Interface
    c.Abstract class
    d.Other

  3. Exception is found in which package in java

  4. a.java.lang
    b.java.util
    c.java.io
    d.java

  5. Exception was introduced in which java version

  6. a.Java 1
    b.Java 2
    c.Java 3
    d.Java 4

  7. Which of these class is highest in hierarchy in java

  8. a.java.lang.Exception
    b.java.lang.Error
    c.java.lang.Throwable
    d.java.lang.Object

  9. What keyword is used to explicitly raise a exception?

  10. a.catch
    b.throw
    c.throws
    d.raise



    Q6 - Q20, 15 MEDIUM level difficulty questions 2 mark each. 2 * 15 = 30 marks

  11. What block is always executed, independently of a exception being raised?

  12. a.throws
    b.finally
    c.catch
    d.throw

  13. Exception and Error are direct subclasses of?

  14. a.BaseException
    b.Throwable
    c.Object
    d.RuntimeException

  15. FileNotFoundException

  16. a.Is a subclass/extends IOException
    b.Is a Compile time exception
    c.Found in java.io package
    d.All

  17. IOException

  18. a.Found in java.io package
    b.Is a Compile time exception
    c.Is a subclass/extends Exception
    d.All

  19. Which of these are java.lang.Error in exception handling in java

  20. a.VirtualMachineError
    b.IOError
    c.AssertionError
    d.ThreadDeath
    e.All

  21. In which condition will the finally block will not be executed?

  22. a.When some Error occurs
    b.When Exception is raised
    c.When System.Exit(1) is called
    d.In all the cases

  23. What type of Exceptions can be ignored at compile time?

  24. a.Runtime
    b.Checked
    c.Both
    d.None

  25. What will be output of following exception handling code in java -


  26. a.ade
    b.adb
    c.bcde
    d.adbe

  27. What will be output of following program -


  28. a.runtime exception
    b.program will compile
    c.program won't compile
    d.

  29. What will happen in this program -


  30. a.StackFlowoverError
    b.compile timeError
    c.StackOverflowException
    d.StackOverflowError

  31. What is invalid statements for automatic resource management in java?

  32. a.Allows us to catch more than one exception in one catch block
    b.We could separate different exceptions using pipe ( | )
    c.Increases developer efforts of writing multiple catch blocks.
    d.None

  33. multiple catch syntax was introduced in ?

  34. a.java 5
    b.java 6
    c.java 7
    d.java 8

  35. Which of these points will be valid If superclass method does not throw any exception

  36. a.overridden method of subclass can throw any RuntimeException
    b.overridden method of subclass cannot throw any checked exception
    c.overridden method of subclass may not throw any exception.
    d.All

  37. What will happen when catch and finally block both return value?

  38. a.method will return value returned by finally block
    b.method will return value returned by catch block
    c.finally block won't execute
    d.None

  39. can a method be overloaded on basis of exceptions ?

  40. a.Will produce runtime error
    b.Will produce compilation error - ambiguity error
    c.Yes a method be overloaded on basis of exceptions.
    d.None



    Q21 - Q25, 5 HARD level difficulty questions 3 mark each.       3 * 5 = 15 marks

  41. What will be output of following program -


  42. a.runtime exception
    b.method return -> finally
    c.method return -> catch
    d.compile timeError

  43. What will be output of following program -


  44. a.abc
    b.abcd
    c.runtime exception
    d.compile timeError

  45. Which is valid about java.lang.Exceptions?

  46. a.The class Exception and all its subclasses that are not also subclasses of RuntimeException are checked exceptions
    b.The class Error and all its subclasses are unchecked exceptions
    c.The class RuntimeException and all its subclasses are unchecked exceptions
    d.All

  47. What is disadvantage/invalid about try-with-resource

  48. a.introduced in java 7
    b.we need not to write explicit code for closing file
    c.Using multiple resources inside Try-with-resources is also allowed
    d.None

  49. FileInputStream implements which interface for closing file automatically in java7?

  50. a.java.lang.AutoClose
    b.java.lang.CloseAutomatically
    c.java.lang.AutoCloseable
    d.java.lang.Closeable





Quiz 1 - Correct answers



EASY
1) a
2) a
3) a
4) d
5) b

MEDIUM
6) b
7) b
8) d
9) d
10) e

11) c
12) a
13) b
14) c
15) d
16) c
17) c
18) d
19) a
20) c

HARD
21) b
22) c
23) d
24) d
25) c

Go to TOP of the page




Exceptions Java - MCQ set 2 (25 questions, 50 marks)



    Q1 - Q5, 5 EASY level difficulty questions 1 mark each. 1 * 5 = 5 marks

  1. What type of Exceptions can NOT be ignored at compile time?

  2. a.Checked Exceptions
    b.Unchecked Exceptions
    c.Uncompiled Exceptions
    d.Error

  3. java.lang.NullPointerException is a

  4. a.Error
    b.runtime exception
    c.Compile time exception
    d.None

  5. What will be output of following program -


  6. a.compile timeError
    b.UserDefinedException will be thrown
    c.UserDefinedException will be thrown and end will be present in output
    d.None

  7. Which of these is valid code snippet in exception handling in java?

  8. a. catch{ }
    b. finally{ }
    c. try{ }finally{ }
    d. try{ }

  9. Which of these will be invalid declaration

  10. a.try-catch block.
    b.
    c.try-catch-finally block.
    d.catch-finally block.



    Q6 - Q20, 15 MEDIUM level difficulty questions 2 mark each. 2 * 15 = 30 marks

  11. What will be output of following program -


  12. a.runtime exception
    b.compilation error
    c.superClass method
    d.SubClass method

  13. What will be output of following exception handling code in java -


  14. a.SubClass method
    b.compilation error
    c.runtime exception
    d.superClass method

  15. What will be output of following exception handling program -


  16. a.after calling m()
    b.runtime exception
    c.program won't compile
    d.None

  17. What will be output of following exception handling code in java -


  18. a.superClass method
    b.runtime exception
    c.compilation error
    d.SubClass method

  19. What will be output of following exception handling program -


  20. a.superClass method
    b.runtime exception
    c.SubClass method
    d.compilation error

  21. What will be output of following exception handling code in java -


  22. a.superClass method
    b.SubClass method
    c.runtime exception
    d.None of these

  23. If superclass method throws unchecked exception then overridden method of subclass can throw

  24. a.Only subclasses of exception thrown by superclass method
    b.Can't throw any exception
    c.Any checked exception
    d.Any runtime exception

  25. What will be output of following program -


  26. a.runtime exception
    b.superClass method
    c.compilation error
    d.SubClass method

  27. If superclass method throws checked exception than

  28. a.overridden method of subclass can declare any RuntimeException
    b.overridden method of subclass can declare narrower checked exception
    c.overridden method of subclass cannot throw broader checked exception
    d.All

  29. Which of these is not a one of the exception handling keyword?

  30. a.finally
    b.exception
    c.try
    d.catch

    e.throw

  31. What is invalid about java.lang.Error in java?

  32. a.Errors are abnormal conditions in application
    b.Error indicates some serious problems that our application should not try to catch
    c.Error is unchecked Exception
    d.Error is a subclass of Throwable

  33. Which of these not a Error?

  34. a.VirtualMachineError
    b.ClassNotFoundError
    c.OutOfMemoryError
    d.IOError

  35. Which is invalid about throws in Exception handling in java?

  36. a.throws can propagate exception to calling method
    b.throws can be used to throw multiple exception at time.
    c.throws is used inside method to throw exception
    d.None of these

  37. What is true about exception handling keyword throw in java

  38. a.throw is a keyword
    b.throw can be used to throw only one exception at time.
    c.throw is used inside method
    d.All

  39. Automatic resource management was introduced in which java version?

  40. a.java 5
    b.java 6
    c.java 7
    d.java 8



    Q21 - Q25, 5 HARD level difficulty questions 3 mark each.       3 * 5 = 15 marks

  41. Which of these is not a good exception handling practice?

  42. a.Throw exceptions when the method cannot handle the exception, and more importantly, must be handled by the caller
    b.log the exception and bubble it
    c.Bubble the exception if the method cannot handle it.
    d.Throw the exception right away

  43. Which are valid statements in Exception handling in java?

  44. a.Java exception handling allows us to use multiple catch block.
    b.Exception class handled in starting catch block must be subclass of Exception class handled in following catch blocks
    c.Either one of the multiple catch block will handle exception at time
    d.All

  45. Which is invalid statement in Exception handling in java?

  46. a.finally block can't throw exception
    b.try block can throw exception
    c.catch block can throw exception
    d.finally block can throw exception

  47. Which of these exceptions are propagated automatically in java?

  48. a.IOException
    b.NullPointerException
    c.ClassNotFoundException
    d.SQLException

  49. Which of these exceptions are always needed to be manually propagated?

  50. a.Error
    b.unchecked exceptions
    c.checked exceptions
    d.None





Quiz 2 - Correct answers



EASY
1) a
2) b
3) b
4) c
5) d

MEDIUM
6) d
7) b
8) b
9) d
10) d

11) b
12) d
13) c
14) d
15) b
16) c
17) b
18) c
19) d
20) c

HARD
21) b
22) d
23) a
24) b
25) c

Go to TOP of the page
Must read for you :

No comments:

Post a Comment