File Handling in Java MCQs 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
Ques 2
File Handling
Which method is used to check if a file exists in Java?
A isFile()
B exists()
C fileExists()
D checkFile()
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
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()
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()
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