Home / Programming Questions / JAVA MCQs / Page 301

JAVA MCQs with answers Page - 301

Dear candidates you will find MCQ questions of JAVA here. Learn these questions and prepare yourself for coming examinations and interviews. You can check the right answer of any question by clicking on any option or by clicking view answer button.
Share your questions by clicking Add Question

M

Mr. Dubey • 51.17K Points
Coach

Q. How many finally blocks can there be in a try/catch structure?

(A) There must be 1.
(B) There can be 1 following each catch block.
(C) There can be 0 or 1 following the last catch block.
(D) ---

M

Mr. Dubey • 51.17K Points
Coach

Q. Which of the following statements is NOT true about creating your own exceptions?

(A) Typically, constructors are the only methods that you include when you define your own exception class.
(B) The exception class that you define extends either the class Throwable or one of its subclasses.
(C) ---
(D) Handle the exception in the try block or handle the exception in the catch block.

M

Mr. Dubey • 51.17K Points
Coach

Q. What can a method do with a checked exception?

(A) Check the exception or ignore it.
(B) Return the exception to the sender or handle it in a catch block.
(C) Throw the exception to the method that called this method, or handle the exception in a catch block.
(D) NumberFormatException

M

Mr. Dubey • 51.17K Points
Coach

Q. Which of the following is an exception thrown by the methods of the class String?

(A) NullPointerException
(B) FileNotFoundException
(C) NoSuchElementsException
(D) None of these

M

Mr. Dubey • 51.17K Points
Coach

Q. Which of the following statements is true?

(A) The class Exception, which is derived from the class Object, is the superclass of the class Throwable.
(B) The class Throwable, which is derived from the class Exception, is the superclass of the class Object.
(C) The class Throwable, which is derived from the class Object, is the superclass of the class Exception.
(D) traceMessage()

M

Mr. Dubey • 51.17K Points
Coach

Q. A message string is returned by which method of an Exception object?

(A) printMessage()
(B) getMessage()
(C) printStackTrace()
(D) Always after the execution of a try block, regardless of whether or not an exception is thrown

M

Mr. Dubey • 51.17K Points
Coach

Q. When is a finally {} block executed?

(A) Only when an exception is thrown by a try block
(B) Only when there are no exceptions thrown
(C) At the end of a program
(D) None of the mentioned

M

Mr. Dubey • 51.17K Points
Coach

Q. When does Exceptions in Java arises in code sequence?

(A) Run Time
(B) Compilation Time
(C) Can Occur Any Time
(D) catch

Login

Forgot username? click here

Forgot password? Click here

Don't have account? Register here.