CH 11
CH 11
File Handling
Textbook MCQ
1. Which of the following statements is true?
(A) Volatile storage lasts only a few seconds.
(B) Volatile storage is lost when a computer is shutdown.
(C) Computer disks are volatile storage devices.
(D) All of these
2. Which of the following refers to a collection of data stored on a non-volatile device in a
Computer system?
(A) File (B) application (C) volatile data (D) hard disk
3. The data hierarchy occurs in which of the following order from the smallest to largest?
(A) file : character : field : record (B) file : character : record : field
(C) character : field : file : record (D) character : field : record : file
4. Which of the following is true about streams?
(A) Streams always flow in two directions
(B) Streams are channels through which the data flow
(C) Only one stream can be open in a program at a time.
(D) All of these
5. Which of the following is used as a separator between fields of a record?
(A) Path (B) delimiter (C) variable (D) space
6. Scanner class can be used to for performing which of the following operations?
(A) Accept input from the keyboard (B) Read from the file
(C) Parse a string separated by delimiters (D) All of these
Extra MCQ
7. By using which method of file output stream classes writes b length bytes form the
specified byte array in Java ?
(A) void write (int b) (B) void write (byte [] b)
(C) void write (int length) (D) void write (byte length)
8. Which method of scanner class of Java, scans the next taken of the input as line?
(A) Boolean has Next() (B) int nextInt()
(C) Float next float() (D) string nextline()
9. Which work can be done in file or directory in Java file class?
(A) Create (B) Rename (C) Delete (D) All of these
10. Which stream is used to make text files and program codes in Java?
(A) byte stream (B) binary stream
(C) character stream (D) input stream
1
11. By which method of file class in Java returns true if the directory exists,otherwise returns
false?
(A) boolean exists() (B) booleanisFile()
(C) booleanisDirectory() (D) String[]list()
12. Which file class method is used to return the number of bytes in that file?
(A) long byte () (B) long file () (C) long number () (D) long length ()
13. Which class is the base for writing a character stream?
(A) Impress (B) Writer (C) Calc (D) Draw
14. What occurs when there is a failed I/O operation in writer class?
(A) IO Base (B) IO throw (C) IO Class (D) IO Exception
15. Which abstract class defines the functionality that is available for all character input
stream?
(A) Text class (B) Void class (C) Reader class (D) Writer class
16. Which File Input Stream method is used to read a byte of data from this input stream?
(A) void read( ) (B) read void( ) (C) void close( ) (D) int read( )
17. Which types of storage values store in variables are lost when computer is shutdown?
(A) Voltage storage (B) Non-voltage storage
(C) Volatile storage (D) Non-volatile storage
18. Which class provides a method for reading password?
(A) Write class (B) Scanner Input class
(C) Reader class (D) Console class
19. Which scanner class method is used to scan the next taken of the input as“int”?
(A) int next Int( ) (B) int has Next( ) (C) void int( ) (D) int next( )
20. Which file class method is used to return the path to the file or directory?
(A) String get Name( ) (B) String get File( )
(C) String get Directory( ) (D) String get Path( )
21. Data stored in files is often called as what?
(A) Persistent data (B) Personal data (C) Provision data (D) Public data
22. Which of the following is an example of binary file?
(A) C (B) mp3 (C) txt (D) java
23. Which class encapsulates information about the properties of a file or a directory?
(A) java.out.file (B) java.in.file (C) java.file.io (D) java.io.File
24. Which file class method is used to return true, if the file or directory is hidden?
(A) boolean is Hidden( ) (B) boolean exists( )
(C) boolean is File( ) (D) boolean is Directory( )
25. Storage device of a computer system can be broadly classified into which categories?
(A) Volatile storage (B) Non-volatile storage (C) Both (A) and (B) (D) Binary storage
2
26. From the following which is not binary file extension?
(A) .jpeg (B) .mp3 (C) .class (D) .txt
27. Which method of file class returns true value if the file or directory is hidden in Java?
(A) boolean is Hidden() (B) boolean is File()
(C) long length() (D) boolean exists()
28. When we write data to stream, which type of stream is known in Java?
(A)Writer stream (B) Output stream (C) Input stream (D) Reader stream
29. Character stream is classified into how many classes?
(A) 1 (B) 2 (C) 3 (D) 4
30. The data hierarchy occurs in which of the following order from the smallest to largest
Piece of data?
(A) file : character : record : field (B) file : character : field : record
(C) character : field : file ; record (D) character : field : record : file
31. Storage device of computer system can be broadly classified into which of the following
category?
(A) Volatile storage (B) Non-volatile storage
(C) Both (A) and (B) (D) Dynamic storage
32. File can exists on which of the following permanent storage device?
(A) Hard disk (B) Compact disc (C) Optical disc (D) All of these
33. Which of the following extension is used for binary files?
(A) .jpeg (B) .mp3 (C) .class (D) All of these
34. In Java, which class encapsulates information about the properties of a file or adirectory?
(A) java.io.object.File (B) java.lang.File
(C) java.util.File (D) java.io.File
35. In Java, which method of file class returns true if file exists otherwise returns false?
(A) boolean FileDir( ) (B) boolean isFile()
(C) boolean listFile() (D) boolean getFile()
36. Java supports which type of streams?
(A) Byte stream (B) Character stream (C) Both (A) and (B) (D) Binary stream
37. In Java, which of the following is a subclass of Reader class?
(A) InputStreamReader (B) BufferedReader
(C) Both (A) and (B) (D) Output stream
38. In Java, which method of file Writer class is used to close the stream?
(A) void close() (B) int break() (C) void terminate() (D) quit()
39. In Java, scanner class can be used to perform which of the following operations?
(A) Read from the file (B) Parse a string separated by delimiters
(C) Accept input form keyboard (D) All of these
3
40. In Java, which of the following is used as a separator between fields of record?
(A) Space (B) Variable (C) Delimiter (D) Path
41. In Java, which method of console class reads a single line of text from the console?
(A) String PrintLine() (B) Char getLine()
(C) Char Print() (D) String readLine()
42. In Java, int read() method returns what to identify the end of data in the stream?
(A) 0 (B) 1 (C) –1 (D) Null
43. Which of the following refers to a collection of data stored on a non-volatile device in a
computer system?
(A) File (B) Volatile data (C) Hard disk (D) Application