Instructions

  • 1. Your final score will reflect your grasp of the concepts—approach each question with precision.
  • 2. Thoroughly review each solution before proceeding to ensure full understanding.
  • 3. Final results will be available after submission to provide insights into areas for further improvement.
  • 4. Maintain academic integrity—plagiarism undermines learning and professional growth.
  • 5. Once submitted, responses are final, so ensure you’re confident in your answers.
  • 6. These challenges are designed to test practical knowledge; apply your skills as you would in real-world scenarios.

All Problems

Question

Action

Which of the following keywords is used to handle exceptions in Java?

View

What will happen if an exception is not caught in a Java program?

View

Which block will always execute, whether an exception is thrown or not?

View

Which of the following is a checked exception?

View

What is the purpose of the throw keyword?

View

What will be the output of the following code?

View

Which exception is thrown when trying to access an array index that is out of bounds?

View

What is the correct way to declare a method that throws an exception?

View

What will happen if an exception is thrown in a try block but there is no corresponding catch block?

View

Which of the following will not compile?

View

Which of the following keywords is used to handle exceptions in Java?

try
catch
throw
All of the above

What will happen if an exception is not caught in a Java program?

The program will terminate
The program will continue
The program will throw a compile-time error
The program will ignore the exception

Which block will always execute, whether an exception is thrown or not?

try
catch
finally
throw

Which of the following is a checked exception?

NullPointerException
ArrayIndexOutOfBoundsException
IOException
ArithmeticException

What is the purpose of the throw keyword?

To throw an exception
To catch an exception
To define a method
To create a new object

What will be the output of the following code?

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

No Exception
Exception caught!
Error
Nothing

Which exception is thrown when trying to access an array index that is out of bounds?

NullPointerException
ArrayIndexOutOfBoundsException
ClassCastException
ArithmeticException

What is the correct way to declare a method that throws an exception?

void myMethod() throws Exception
void myMethod() catch Exception
void myMethod() throw Exception
void myMethod() final

What will happen if an exception is thrown in a try block but there is no corresponding catch block?

The program will crash
The program will continue running
The finally block will execute
Both B and C

Which of the following will not compile?

throw new Exception();
try { ... }
catch (Exception e) { ... }
throw new RuntimeException();