Exam 7: Inputoutput and Exception Handling
Exam 1: Introduction96 Questions
Exam 2: Fundamental Data Types103 Questions
Exam 3: Decisionseasy99 Questions
Exam 4: Loops100 Questions
Exam 5: Methods94 Questions
Exam 6: Arrays and Arraylists100 Questions
Exam 7: Inputoutput and Exception Handling100 Questions
Exam 8: Objects and Classes101 Questions
Exam 9: Inheritance and Interfaces99 Questions
Exam 10: Graphical User Interfaces54 Questions
Exam 11: Advanced User Interfaces91 Questions
Exam 12: Object-Oriented Design100 Questions
Exam 13: Recursion100 Questions
Exam 14: Sorting and Searching99 Questions
Exam 15: The Java Collections Framework100 Questions
Exam 16: Basic Data Structures94 Questions
Exam 17: Tree Structures100 Questions
Exam 18: Generic Classes78 Questions
Exam 19: Streams and Binary Inputoutput82 Questions
Exam 20: Multithreading82 Questions
Exam 21: Internet Networking74 Questions
Exam 22: Relational Databases75 Questions
Exam 23: XML74 Questions
Exam 24: Web Applications74 Questions
Select questions type
When a program throws an exception within a method that has no try-catch block, which of the following statements about exception handling is true?
(Multiple Choice)
5.0/5
(32)
Which Java class implements a file dialog box for selecting a file by a program with a graphical user interface?
(Multiple Choice)
4.8/5
(30)
Consider the following code snippet:
PrintWriter outputFile = new PrintWriter(filename);
WriteData(outputFile);
OutputFile.close();
How can the program ensure that the file will be closed if an exception occurs on the writeData call?
(Multiple Choice)
4.9/5
(44)
The Scanner class's ____ method is used to specify a pattern for word boundaries when reading text.
(Multiple Choice)
4.8/5
(41)
Consider the following code snippet:
If (in.hasNextDouble())
{
Number = in.nextDouble();
}
Result = in.next();
If the input contains the characters 626.14 average, what values will number and result have after this code is executed?
(Multiple Choice)
4.9/5
(39)
Which of the following statements about a PrintWriter object is true?
(Multiple Choice)
4.9/5
(31)
Under which condition will the Scanner constructor generate a FileNotFoundException?
(Multiple Choice)
4.8/5
(33)
Consider the following code snippet:
Scanner in = new Scanner(. . .);
In)useDelimiter("[^0-9]+");
What characters will be ignored and not read in using this code?
(Multiple Choice)
4.8/5
(43)
Which return value of the JFileChooser object's showOpenDialog method indicates that a file was chosen by the user at run time?
(Multiple Choice)
4.9/5
(42)
Insert the missing code in the following code fragment. This fragment is intended to read an input file named dataIn.txt and write to an output file named dataOut.txt.
Public static void main(String[] args) throws FileNotFoundException
{
String inputFileName = "dataIn.txt";
String outputFileName = "dataOut.txt";
File inputFile = _________________;
Scanner in = new Scanner(inputFile)
) . .
}
(Multiple Choice)
4.7/5
(38)
When writing a method, which of the following statements about exception handling is true?
(Multiple Choice)
4.9/5
(37)
Consider the following code snippet:
Try
{
PrintWriter outputFile = new PrintWriter(filename);
Try
{
WriteData(outputFile);
}
Finally
{
OutputFile.close();
}
}
Catch (IOException exception)
{
) . .
}
Which of the following statements about this code is correct?
(Multiple Choice)
4.9/5
(42)
Consider the following code snippet:
File inputFile = new File("input.txt");
You wish to read the contents of this file using a Scanner object. Which of the following is the correct syntax for doing this?
(Multiple Choice)
4.9/5
(33)
Which of the following statements about reading and writing binary data is correct?
(Multiple Choice)
4.8/5
(44)
Which of the following statements about reading and writing text files is correct?
(Multiple Choice)
4.8/5
(45)
Which of the following is the correct syntax for creating a File object?
(Multiple Choice)
4.8/5
(39)
Insert the missing code in the following code fragment. This fragment is intended to read a web page.
Public static void main(String[] args) throws IOException
{
String address = "http://horstmann.com/index.html";
URL pageLocation = new URL(address);
Scanner in = _________;
) . .
}
(Multiple Choice)
4.7/5
(30)
The ____ method of the Character class will indicate if a character contains white space.
(Multiple Choice)
4.8/5
(34)
Which of the following statements about using a PrintWriter object is NOT true?
(Multiple Choice)
4.9/5
(38)
Consider the following code snippet.
File inputFile = new File("dataIn.txt");
Scanner in = new Scanner(inputFile);
While (in.hasNext())
{
String input = in.next();
}
Which of the following statements about this code is correct?
(Multiple Choice)
4.9/5
(36)
Showing 61 - 80 of 100
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)