21. In Java, how can you check if a file or directory exists using the `File` class? A. By using the `createNewFile()` method B. By using the `read()` method C. By using the `exists()` method D. By using the `write()` method Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option C No explanation is given for this question Let's Discuss on Board
22. Which method is used to delete a file or directory in Java? A. `erase()` B. `delete()` C. `discard()` D. `erase()` Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option B No explanation is given for this question Let's Discuss on Board
23. In Java, what is the purpose of the `File.separator` constant? A. It represents the parent directory B. It represents the current directory C. It represents the platform-specific file separator (e.g., `/` or ``) D. It represents the ASCII value of the separator character Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option C No explanation is given for this question Let's Discuss on Board
24. What is the difference between character streams and byte streams in Java? A. Character streams are used for reading and writing binary data, while byte streams are used for text data B. There is no difference between character streams and byte streams C. Character streams are more efficient than byte streams D. Character streams are used for reading and writing text data, while byte streams are used for reading and writing binary data Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option D No explanation is given for this question Let's Discuss on Board
25. In Java, what is the purpose of the `BufferedWriter` class? A. It is used to write character data to a file efficiently B. It is used to write binary data to a file C. It is used to read character data from a file D. It is used to read binary data from a file Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option A No explanation is given for this question Let's Discuss on Board
26. Which class is used for reading character streams in a platform-independent way in Java? A. `BufferedReader` B. `DataInputStream` C. `FileReader` D. `InputStreamReader` Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option D No explanation is given for this question Let's Discuss on Board
27. In Java, what is the primary purpose of the `PrintStream` class? A. It is used to read binary data from a file B. It is used to write binary data to a file C. It is used to write formatted text to an output stream D. It is used to read text data from the keyboard Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option C No explanation is given for this question Let's Discuss on Board
28. What is the difference between reading and writing character streams in Java? A. Both reading and writing character streams use `InputStream` classes B. Reading character streams use `Reader` classes, while writing character streams use `Writer` classes C. Both reading and writing character streams use `OutputStream` classes D. Both reading and writing character streams use `InputStream` classes Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option B No explanation is given for this question Let's Discuss on Board
29. In Java, which class is used to read binary data from an input stream? A. `PrintStream` B. `BufferedReader` C. `DataInputStream` D. `FileInputStream` Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option C No explanation is given for this question Let's Discuss on Board
30. What is the purpose of the `Console` class in Java? A. It provides methods for reading and writing binary data B. It provides methods for creating directories C. It provides methods for performing mathematical operations D. It provides methods for reading and writing character-based console input and output Answer & Solution Discuss in Board Save for Later Answer & Solution Answer: Option D No explanation is given for this question Let's Discuss on Board