MCQOPTIONS
Saved Bookmarks
This section includes 10 Mcqs, each offering curated multiple-choice questions to sharpen your Advanced Java knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
AutoCloseable and Flushable are part of which package? |
| A. | Autocloseable java.lang; Flushable java.io |
| B. | Autocloseable java.io; Flushable java.lang |
| C. | Autocloseable and Flushable java.io |
| D. | Autocloseable and Flushable java.lang |
| Answer» B. Autocloseable java.io; Flushable java.lang | |
| 2. |
Does close() implicitly flush() the stream. |
| A. | True |
| B. | False |
| Answer» B. False | |
| 3. |
Which version of java added Flushable interface? |
| A. | java SE 7 |
| B. | java SE 8 |
| C. | java SE 6 |
| D. | java SE 5 |
| Answer» E. | |
| 4. |
What is the use of Flushable interface? |
| A. | Flushes this stream by writing any buffered output to the underlying stream |
| B. | Flushes this stream and starts reading again |
| C. | Flushes this connection and closes it |
| D. | Flushes this stream and throws FlushException |
| Answer» B. Flushes this stream and starts reading again | |
| 5. |
What is the difference between AutoCloseable and Closeable? |
| A. | Closeable is an interface and AutoCloseable is a concrete class |
| B. | Closeable throws IOException; AutoCloseable throws Exception |
| C. | Closeable is a concept; AutoCloseable is an implementation |
| D. | Closeable throws Exception; AutoCloseable throws IOException |
| Answer» C. Closeable is a concept; AutoCloseable is an implementation | |
| 6. |
It is a good practise to not throw which exception in close() method of autocloseable? |
| A. | IOException |
| B. | CustomException |
| C. | InterruptedException |
| D. | CloseException |
| Answer» D. CloseException | |
| 7. |
Which of the below is a child interface of Autocloseable? |
| A. | Closeable |
| B. | Close |
| C. | Auto |
| D. | Cloneable |
| Answer» B. Close | |
| 8. |
Autocloseable was introduced in which Java version? |
| A. | java SE 7 |
| B. | java SE 8 |
| C. | java SE 6 |
| D. | java SE 4 |
| Answer» B. java SE 8 | |
| 9. |
DOES_CLOSE()_IMPLICITLY_FLUSH()_THE_STREAM.?$ |
| A. | True |
| B. | False |
| Answer» B. False | |
| 10. |
What is the alternative of using finally to close resource? |
| A. | catch block |
| B. | autocloseable interface to be implemented |
| C. | try block |
| D. | throw Exception |
| Answer» C. try block | |