Presentation is loading. Please wait.

Presentation is loading. Please wait.

COMP249 File I/O.

Similar presentations

Presentation on theme: "COMP249 File I/O."— Presentation transcript:

1 COMP249 File I/O

2 Question1 There are two common classes used for reading from a text file. They are: a. PrintWriter and BufferedReader b. FileInputStream and Scanner c. BufferedReader and Scanner d. None of the above Answer: c

3 Question 2 The scanner class has a series of methods that checks to see if there is any more well-formed input of the appropriat type. These methods are called __________methods nextToken hasNext getNext testNext Answer: B

4 Question 3 Which statement is true? A.It a good idea to close a file to which you have written, even though Java will close it for you when your program ends, because if your program ends abnormally, the file may not be properly closed, or it may become otherwise corrupted. B. There is no reason to waste time closing a file that will be closed automatically. C. Closing a file makes your program run more efficiently. D. Java doesn't close files that YOU open explicitly - it only automatically closes, System.out, and System.err. Answer: A

5 Question 4 Which of the following are true? i. The classes Reader and Writer deal with text files while the classes ObjectOutputStream and ObjectInputStream deal with binary files. ii. Buffering an output file insures that every write operation calls the operating system immediately to physically write the data in the file. iii. Dealing with files can throw unchecked exceptions. iv. Binary files created by a Java program are more portable because they can be read on any platform using any program written in any language. a) True: All statements b) True: i, ii c) True: Only i d) True: i, ii, iii, and iv Answer:C

6 Question 5 In Java, when you open a text file you should account for a possible: FileNotFoundException FileFullException FileNotReadyException all of the above Answer:A

Download ppt "COMP249 File I/O."

Similar presentations

Ads by Google