Files and I/O


  1. Which jar provides FileUtils which contains methods for file operations?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    FileUtils is a part of apache commons which provides various methods for file operations like writeStringToFile.


  1. Which feature of java 7 allows to not explicitly close IO resource?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    Any class that has implemented Autocloseable releases the I/O resources.



  1. Which of these methods is used to write() into a file?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    write()


  1. Which of these exception is thrown by close() and read() methods?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    Both close() and read() method throw IOException.



  1. Which of these values is returned by read() method is end of file (EOF) is encountered?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    Each time read() is called, it reads a single byte from the file and returns the byte as an integer value. read() returns -1 when the end of the file is encountered.