This section contains carefully selected MCQs and Previous Year Questions with explanations to help students understand concepts and prepare effectively for examinations, interviews, and competitive tests.
Q: 1Which of these exceptions is thrown in cases when the file specified for writing is not found?
Option C
In Java, when a program attempts to open a file for reading or writing and that file does not exist or cannot be located in the specified path, Java throws a FileNotFoundException. This exception is a subclass of IOException and specifically indicates problems related to missing files.
Q: 2In the context of error handling in C++ and Java, which of the following is true about ‘finally’?
Option D
In Exception Handling (Java), the finally block is used to execute important code such as closing files or releasing resources. It is designed to run no matter what happens in the try block.
Whether an exception occurs or not, and even if it is handled or not, the finally block is always executed.
Q: 3Which of these classes are the direct subclasses of the Throwable Class?
Option B
In Java, Throwable is the root class for all exceptions and errors that can occur during program execution. It defines the common behavior for objects that can be thrown using the throw keyword. It has two direct subclasses, Error and Exception.

Note:
You have reached the end of this topic. Continue learning with the next topic below.
Thank you so much for taking the time to read my Computer Science MCQs section carefully. Your support and interest mean a lot, and I truly appreciate you being part of this journey. Stay connected for more insights and updates! If you'd like to explore more tutorials and insights, check out my YouTube channel.
Don’t forget to subscribe and stay connected for future updates.