Java File Handling MCQs

This section focuses on the "Java File Handling" in Java programming. These Multiple Choice Questions (MCQ) should be practiced to improve the Java programming skills required for various interviews (campus interview, walk-in interview, company interview), placements, entrance exams and other competitive examinations.

1. which class is used to work with files in java?

A. Except class
B. File Class
C. This class
D. io class

View Answer


2. File Class is inside which package?

A. java.util
B. java.awt
C. java.lang
D. java.io

View Answer


3. File handling means _______________ to a file.

A. reading data
B. writing data
C. reading and writing data
D. None of the above

View Answer


4. In Java, a sequence of data is known as a stream.

A. TRUE
B. FALSE
C. Can be true or false
D. Can not say

View Answer


5. How many types of streams there in java?

A. 1
B. 2
C. 3
D. 4

View Answer


6. Which method is used to reads one byte of data from the input stream?

A. mark()
B. input()
C. read()
D. reset()

View Answer


7. Which method is used to forces to write all the data present in an output stream to the destination?

A. close()
B. write()
C. flush()
D. Any of the above

View Answer


8. Which method is used to create a new file in Java?

A. file.createNewFile()
B. file.createFile()
C. file.addFile()
D. file.makeFile()

View Answer


9. Which method is used to delete a file in Java?

A. file.deleteFile()
B. file.remove()
C. file.erase()
D. file.delete()

View Answer


10. The input stream is used to read data from numerous input devices like the keyboard, network, etc.

A. TRUE
B. FALSE
C. Can be true or false
D. Can not say

View Answer



Discussion



* You must be logged in to add comment.