Questions 9, 11, 15, 19, 24, 26, 29, 33, 35, 43, 52, 57, 63, 64, 65 all require
ID: 3858323 • Letter: Q
Question
Questions 9, 11, 15, 19, 24, 26, 29, 33, 35, 43, 52, 57, 63, 64, 65 all require pictures to answer, the link to the associated pictures is provided below
https://drive.google.com/open?id=0B8Jh4LT8NcplaGhTVFpJOEhLcU0
A. The program aborts with an exception
B. A compile error at line 11 will occur because doit needs to surround the throw statement with try-catch logic, or change it's declaration to:
void doit throws MyError1
C. The program will run and generate the output "Exception"
D. The program will run and generate the output "MyError1"
E. The program will run and generate the output "RuntimeException"
Pick the code which replaces line 25 and fixes this compile error and uses the MyMouseHandler class to process Mouse Clicks.
A. this.addMouseListener();
B. addMouseListener(this.JFrame);
C. MyMouseHandler mmh = new MyMouseHandler();
mmh.addMouseListener();
D. addMouseListener( new MyMouseHandler());
A. A compile error at line 11 will occur because doit needs to surround the throw statement with try-catch logic, or change it's declaration to:
void doit throws MyError1
B. The program aborts with an exception
C. The program will run and generate the output "Exception"
D. The program will run and generate the output "RuntimeException"
E. The program will run and generate the output "MyError1"
Question 63
1. Which statement is true about the following code
B. This code will not compile unless we catch the "FileNotFoundException"
D. There is a compile error because ObjectOutputStream does not have a constructor which takes a FileOutputStream as it's only parameter.
F. This will not compile unless the Data class implements the FileWriteable interface
H. A compile error occurs because the Data class does not implement the methods in the Serializable interface
J. A Binary file with the name of file.dat will be created that contains the binary contents of the array "arr"
3 points
Question 64
1. On line 6, what happens if you remove the "implements Serializable"
a. The new line 6 would just be:
class Data
D. A Binary file with the name of file.dat will be created that contains the binary contents of the array "arr"
G. The ObjectOutputStream cannot be written because Data does not implement Serializable. An exception occurs instead.
J. This code will not compile unless we catch the "FileNotFoundException"
M. This will not compile unless the Data class implements the FileWriteable interface
P. There is a compile error because ObjectOutputStream does not have a constructor which takes a FileOutputStream as it's only parameter.
3 points
Question 65
1. Which statement is true about the following code
A. If the file abc.txt exists, this code will read the first string found on the line into the variable "s"
B. A compile error occurs because we need to surround line 10 with try-catch logic to catch a "FileNotFoundException"
C. If the file abc.txt exists, this code will read the first line of text into the variable "s"
D. A compile error occurs because this code cannot throw an "IOException"
A. The program aborts with an exception
B. A compile error at line 11 will occur because doit needs to surround the throw statement with try-catch logic, or change it's declaration to:
void doit throws MyError1
C. The program will run and generate the output "Exception"
D. The program will run and generate the output "MyError1"
E. The program will run and generate the output "RuntimeException"
Explanation / Answer
43. B. A compile error at line 11 will occur because doit needs to surround the throw statement with try-catch logic, or change it's declaration to:
void doit throws MyError1
52. addMouseListener( new MyMouseHandler());
57. A compile error at line 11 will occur because doit needs to surround the throw statement with try-catch logic, or change it's declaration to:
void doit throws MyError1
63. A Binary file with the name of file.dat will be created that contains the binary contents of the array "arr"
64. A Binary file with the name of file.dat will be created that contains the binary contents of the array "arr"
65. If the file abc.txt exists, this code will read the first line of text into the variable "s"
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.