File Handling in Java Exercise I


Ques 1 File Handling


Which class is used to perform file input/output operations in Java?
  a) FileReader
  b) FileWriter
  c) FileHandler
  d) FileIO


a is the correct option




Ques 2 File Handling


Which method is used to check if a file exists in Java?
  a) isFile()
  b) exists()
  c) fileExists()
  d) checkFile()


b is the correct option




Ques 3 File Handling


Which class is used to write data to a file in a buffered manner in Java?
  a) FileWriter
  b) FileOutputWriter
  c) BufferedWriter
  d) OutputStreamWriter


c is the correct option




Ques 4 File Handling


Which method is used to check if a file is hidden in Java?
  a) hide()
  b) setHidden()
  c) isHidden()
  d) checkHidden()


c is the correct option




Ques 5 File Handling


Which method is used to get the length of a file in Java?
  a) length()
  b) getSize()
  c) getFileSize()
  d) size()


a is the correct option




Ques 6 File Handling


What will be the output of the following code snippet?

File file = new File("sample.txt");
System.out.println(file.length());

  a) Size of the file in bytes
  b) Size of the file in kilobytes
  c) Compilation error
  d) Runtime error


a is the correct option