1 Which of the following classes is not used for file input
1: Which of the following classes is not used for file input?
a. FileInputStream
b. FileReader
c. ObjectInputStream
d. Formatter
2: Streams that input bytes from and output bytes to files are known as:
a. bit-based streams
b. byte-based streams
c. character-based streams
d. Unicode-based streams
3: Which of the following statements is not equivalent to
File name = new File( \"c:\\\\books\\\\2009\\\\files.txt\" );
Assume we are currently in the directory c:\\books.
a. File name = new File( \"c:\\\\books\\\\2009\", \"files.txt\" );
b. File name = new File( \"files.txt\" );
c. File name = new File( \"2009\", \"files.txt\" );
d. All of the above are equivalent to the statement in the question.
4: Which of the following is not an application of a File object?
a. Open or edit a file.
b. Determine if a file exists.
c. Determine whether a file is readable.
d. Determine whether a file is writable.
5: When all the contents of a file are truncated, this means that:
a. the data in the file is saved to a backup file.
b. the file is deleted.
c. a FileNotFoundException occurs.
d. All the data in the file is discarded.
6: To catch an exception, the code that might throw the exception must be enclosed in a
a. throws block.
b. catch block.
c. try block.
d. finally block.
7: In the catch block below, what is arithmeticException?
catch ( ArithmeticException arithmeticException )
{
System.err.printf( arithmeticException );
} // end catch
a. The type of the exception being caught.
b. The name of catch block’s exception parameter.
c. A finally block.
d. An exception handler.
8: An uncaught exception:
a. is a possible exception that never actually occurs during the execution of the program.
b. is an exception that occurs for which the matching catch clause is empty.
c. is an exception that occurs for which there are no matching catch clauses.
d. is another term for a thrown exception.
9: Which of the following exceptions is a checked exception?
a. ArithmeticException.
b. IOException.
c. RuntimeException.
d. InputMismatchException.
10: If the catch-or-declare requirement for a checked exception is not satisfied:
a. the compiler will issue an error message indicating that the exception must be caught.
b. the compiler will issue an error message indicating that the exception must be caught or declared.
c. a stack trace will be displayed indicating the exception that has occurred and where it occurred.
d. a stack trace will be displayed, along with a message indicating that the exception must be caught.
Solution
Answer :
1: Which of the following classes is not used for file input?
a. FileInputStream
b. FileReader
c. ObjectInputStream
d. Formatter
Answer :
d.Formatter
Because FileInputStream,FileReader,ObjectInputStream classes are related to file input.
2: Streams that input bytes from and output bytes to files are known as:
a. bit-based streams
b. byte-based streams
c. character-based streams
d. Unicode-based streams
Answer :
b.byte-based streams
Byte-based streams representing data in its can binary format.Files that are created using byte-based streams are known as binary files.
3: Which of the following statements is not equivalent to
File name = new File( \"c:\\\\books\\\\2009\\\\files.txt\" );
Assume we are currently in the directory c:\\books.
a. File name = new File( \"c:\\\\books\\\\2009\", \"files.txt\" );
b. File name = new File( \"files.txt\" );
c. File name = new File( \"2009\", \"files.txt\" );
d. All of the above are equivalent to the statement in the question.
Answer :
d. All of the above are equivalent to the statement in the question.
4: Which of the following is not an application of a File object?
a. Open or edit a file.
b. Determine if a file exists.
c. Determine whether a file is readable.
d. Determine whether a file is writable.
Answer :
a. Open or edit a file.
5: When all the contents of a file are truncated, this means that:
a. the data in the file is saved to a backup file.
b. the file is deleted.
c. a FileNotFoundException occurs.
d. All the data in the file is discarded.
Answer :
d. All the data in the file is discarded.
6: To catch an exception, the code that might throw the exception must be enclosed in a
a. throws block.
b. catch block.
c. try block.
d. finally block.
Answer :
c.try block
7: In the catch block below, what is arithmeticException?
catch ( ArithmeticException arithmeticException )
{
System.err.printf( arithmeticException );
} // end catch
a. The type of the exception being caught.
b. The name of catch block’s exception parameter.
c. A finally block.
d. An exception handler.
Answer :
b. The name of catch block’s exception parameter.
8: An uncaught exception:
a. is a possible exception that never actually occurs during the execution of the program.
b. is an exception that occurs for which the matching catch clause is empty.
c. is an exception that occurs for which there are no matching catch clauses.
d. is another term for a thrown exception.
Answer :
c. is an exception that occurs for which there are no matching catch clauses.
9: Which of the following exceptions is a checked exception?
a. ArithmeticException.
b. IOException.
c. RuntimeException.
d. InputMismatchException.
Answer :
b. IOException.
10: If the catch-or-declare requirement for a checked exception is not satisfied:
a. the compiler will issue an error message indicating that the exception must be caught.
b. the compiler will issue an error message indicating that the exception must be caught or declared.
c. a stack trace will be displayed indicating the exception that has occurred and where it occurred.
d. a stack trace will be displayed, along with a message indicating that the exception must be caught.
Answer :
b. the compiler will issue an error message indicating that the exception must be caught or declared.



