Java File Writing

Last Updated :
Discuss
Comments

Question 1

Which Java class is primarily used to write character data to files?

  • FileReader

  • FileWriter

  • FileInputStream

  • BufferedReader

Question 2

Which method is used to write a single character using FileWriter?

  • append()

  • writeChar()

  • write()

  • print()

Question 3

Which class provides buffering for efficient writing of text data to files?


  • FileReader

  • FileInputStream

  • BufferedWriter

  • PrintStream

Question 4

What does the append() method of FileWriter do?

  • Replaces the existing file content

  • Adds text to the beginning of the file

  • Adds text to the end of the file

  • Creates a new file always

Question 5

Which of the following correctly closes the FileWriter?

  • fw.stop()

  • fw.flush()

  • fw.close()

  • fw.dispose()

Question 6

What does the Writer class in Java primarily handle?

  • Reading binary data from a file

  • Writing text data to a file

  • Writing binary data to a file

  • Reading text data from a file

Question 7

Which of the following is true about Writer and Reader classes in Java I/O?

  • Writer handles character streams, while Reader handles byte streams

  • Writer and Reader are used for handling character streams

  • Writer handles byte streams, while Reader handles character streams

  • Both handle binary data

Question 8

Which of the following is a subclass of Writer in Java?

  • FileReader

  • OutputStreamWriter

  • BufferedReader

  • FileInputStream

There are 8 questions to complete.

Take a part in the ongoing discussion