All of these are Java questions. Please only answer if you are sure your answer
ID: 3697752 • Letter: A
Question
All of these are Java questions. Please only answer if you are sure your answer is correct. Negative reviews will be given incorrect answers.
1D.
Which of the following statements about reading and writing binary data is correct?
Select one:
a. You use the Scanner class to read and write binary data.
b. You use the PrintWriter class to read and write binary data.
c. You use the InputStream class to read binary data and the FileOutputStream class to write binary data.
d. You use the InputStream class to write binary data and the FileOutputStream class to read binary data.
2D.
Which of the following statements about the finally clause in a try block is NOT true?
Select one:
a. The finally clause will be executed after the last statement of the try block completes without exception.
b. The finally clause will be executed after the last statement of a catch clause completes if this try block catches an exception.
c. If no exception occurs, the finally clause will not be executed.
d. The finally clause will be executed when an exception is thrown in the try block but not caught.
3D.
Insert the missing code in the following code fragment. This fragment is intended to read an input file named dataIn.txt that resides in a folder named payroll on the C: drive of a Windows system.
Select one:
a. new File(c:/payroll/"dataIn.txt")
b. new File(c://payroll//"dataIn.txt")
c. new File("c:payrolldataIn.txt")
d. new File("c:\payroll\dataIn.txt")
4D.
In the hierarchy of Exception classes, the NumberFormatException class is a subclass of the ____ class.
Select one:
a. ArithmeticException.
b. ClassCastException.
c. IllegalArgumentException.
d. IllegalStateException.
5D.
Consider the following code snippet:
What is wrong with this code?
Select one:
a. The program will attempt to close the file even if it has not been successfully opened.
b. This code will not handle write errors.
c. This code will ensure the data is written properly.
d. There is nothing wrong with this code.
Explanation / Answer
1.D.(C)You use the InputStream class to read binary data and the FileOutputStream class to write binary data.
2D.c. If no exception occurs, the finally clause will not be executed.
3D.c. new File("c:payrolldataIn.txt")
4D.a. ArithmeticException.
5D.b. This code will not handle write errors.