Bird
0
0

What does the throw keyword do in Java?

easy📝 Conceptual Q11 of 15
Java - Exception Handling

What does the throw keyword do in Java?

AIt catches an exception and handles it.
BIt sends an exception to stop normal program flow when an error occurs.
CIt declares a method can throw exceptions.
DIt creates a new thread for parallel execution.
Step-by-Step Solution
Solution:
  1. Step 1: Understand the role of throw

    The throw keyword is used to send an exception object explicitly when an error happens.
  2. Step 2: Differentiate from other keywords

    throw does not catch exceptions (that's catch), nor declare exceptions (that's throws), nor create threads.
  3. Final Answer:

    It sends an exception to stop normal program flow when an error occurs. -> Option B
  4. Quick Check:

    throw sends exception = B [OK]
Quick Trick: Remember: throw sends, catch handles exceptions [OK]
Common Mistakes:
  • Confusing throw with throws keyword
  • Thinking throw catches exceptions
  • Mixing throw with thread creation

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Java Quizzes