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
Your program will read in an existing text file. You want the program to terminate if the file does not exist. Which of the following indicates the correct code for the main method header?
(Multiple Choice)
4.9/5
(32)
Insert the missing code in the following code fragment. This fragment is intended to read all words from a text file.
File inputFile = new File("dataIn.txt");
Scanner in = new Scanner(dataIn.txt);
While (____________)
{
String input = in.next();
System.out.println(input);
}
(Multiple Choice)
4.8/5
(35)
Consider the following code snippet:
Scanner in = new Scanner(. . .);
In)useDelimiter("[A-Za-z]+");
What characters will be read in using this code?
(Multiple Choice)
4.8/5
(44)
Consider the following code snippet:
Scanner in = new Scanner(. . .);
While (in.hasNextInt())
{
) . .
}
Under which condition will the body of the while loop be processed?
(Multiple Choice)
4.8/5
(39)
When reading words with a Scanner object, a word is defined as ____.
(Multiple Choice)
4.7/5
(38)
Which of the following statements about exception reporting is true?
(Multiple Choice)
4.8/5
(36)
Your program wishes to open a file named C:\java\myProg\input.txt on a Windows system. Which of the following is the correct code to do this?
(Multiple Choice)
4.8/5
(34)
Which of the following statements about exception handling is recommended by the textbook?
(Multiple Choice)
4.8/5
(28)
Consider the following code snippet written in Java 7:
Try (PrintWriter outputFile = new PrintWriter(filename))
{
WriteData(outputFile);
}
Which of the following statements about this Java 7 code is correct?
(Multiple Choice)
4.9/5
(40)
Consider the following code snippet:
Scanner in = new Scanner(. . .);
While (in.hasNextInt())
{
) . .
}
Under which condition will the body of the while loop be processed?
(Multiple Choice)
4.9/5
(33)
Your program must read in an existing text file. You want the program to terminate if the file does not exist. Which of the following indicates the correct code for the main method header?
(Multiple Choice)
4.8/5
(40)
Consider the following code snippet:
Scanner in = new Scanner(. . .);
Int ageValue = in.nextInt();
If there is no integer number appearing next in the input, what will occur?
(Multiple Choice)
4.7/5
(35)
Consider the following code snippet:
Public double[] readInputFile(String filename) throws IOException
{
File inputFile = new File(filename);
Scanner in = new Scanner(inputFile);
Try
{
ReadData(in);
Return data;
}
Finally
{
InputFile.close();
}
}
Which of the following statements about this method's code is correct?
(Multiple Choice)
4.8/5
(42)
Consider the following code snippet.
Scanner in = new Scanner(. . .);
While (in.hasNextDouble())
{
Double input = in.nextDouble();
}
Which of the following statements about this code is correct?
(Multiple Choice)
4.8/5
(40)
Consider the following code snippet.
Scanner in = new Scanner(. . .);
While (in.hasNextLine())
{
String input = in.nextLine();
}
Which of the following statements about this code is correct?
(Multiple Choice)
4.8/5
(33)
Insert the missing code in the following code fragment. This fragment is intended to write an output file named dataOut.txt that resides in a folder named reports on the C: drive of a Windows system.
Public static void main(String[] args) throws IOException
{
PrintWriter outputFile = _______;
) . .
}
(Multiple Choice)
4.9/5
(36)
The Java compiler requires that your program handle which type of exceptions?
(Multiple Choice)
4.9/5
(42)
Which of the following statements about the finally clause in a try block is NOT true?
(Multiple Choice)
4.8/5
(38)
Consider the following code snippet:
Public static void main(String[] args) throws FileNotFoundException
Which of the following statements about this code is correct?
(Multiple Choice)
4.8/5
(36)
Showing 81 - 100 of 100
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)