JAVA MCQs with answers Page - 354

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

N

Neelam Mittal • 4.57K Points
Extraordinary

Q. What is the purpose of the "throw" keyword in Java exception handling?

  • (A) To explicitly throw an exception
  • (B) To catch exceptions
  • (C) To specify exception types
  • (D) To declare a method as "throws"

V

Vijay Sangwan • 28.62K Points
Instructor II

Q. In Java, can a method throw any checked exception without declaring it using "throws"?

  • (A) Only if the exception is marked as "static"
  • (B) Only if the method is marked as "final"
  • (C) No, a method must declare checked exceptions using the "throws" keyword
  • (D) Yes, a method can throw any checked exception without declaration

R

Ram Avtar Sharma • 4.50K Points
Extraordinary

Q. What is the purpose of the "throws" keyword in Java method declaration?

  • (A) To indicate that the method will throw an unchecked exception
  • (B) To specify the exception message
  • (C) To indicate that the method may throw a checked exception
  • (D) To specify the exception type

V

Vikash Gupta • 33.56K Points
Instructor I

Q. What is the result of the following code snippet?

try {
int[] arr = new int[5];
int value = arr[10];
} catch (ArrayIndexOutOfBoundsException e) {
System.out.println("Exception Caught!");
}

  • (A) Compilation error
  • (B) Exception Caught!
  • (C) Runtime exception
  • (D) Bounds Exception

Be the first to start discuss.

Download our easy to use, user friendly Android App from Play Store. And learn MCQs with one click.

Image

Login

Forgot username? click here

Forgot password? Click here

Don't have account? Register here.