Java File Writing

Last Updated :
Discuss
Comments

Question 1

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

  • A

    FileReader

  • B

    FileWriter

  • C

    FileInputStream

  • D

    BufferedReader

Question 2

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

  • A

    append()

  • B

    writeChar()

  • C

    write()

  • D

    print()

Question 3

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


  • A

    FileReader

  • B

    FileInputStream

  • C

    BufferedWriter

  • D

    PrintStream

Question 4

What does the append() method of FileWriter do?

  • A

    Replaces the existing file content

  • B

    Adds text to the beginning of the file

  • C

    Adds text to the end of the file

  • D

    Creates a new file always

Question 5

Which of the following correctly closes the FileWriter?

  • A

    fw.stop()

  • B

    fw.flush()

  • C

    fw.close()

  • D

    fw.dispose()

Question 6

What does the Writer class in Java primarily handle?

  • A

    Reading binary data from a file

  • B

    Writing text data to a file

  • C

    Writing binary data to a file

  • D

    Reading text data from a file

Question 7

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

  • A

    Writer handles character streams, while Reader handles byte streams

  • B

    Writer and Reader are used for handling character streams

  • C

    Writer handles byte streams, while Reader handles character streams

  • D

    Both handle binary data

Question 8

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

  • A

    FileReader

  • B

    OutputStreamWriter

  • C

    BufferedReader

  • D

    FileInputStream

There are 8 questions to complete.

Take a part in the ongoing discussion