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
Insert the missing code in the following code fragment. This code is intended to open a file and handle the situation where the file cannot be found.
Public void String readFile() throws IOException
{
File inputFile = new File(. . .);
Scanner in = new Scanner(inputFile);
Try
{
While (in.hasNext())
{
) . .
}
}
Finally
{
___________________
}
}
(Multiple Choice)
4.8/5
(33)
Insert the missing code in the following code fragment. This fragment is intended to read an input file.
Public static void main(String[] args) __________________
{
String inputFileName = "dataIn.txt";
File inputFile = new File(inputFileName);
Scanner in = new Scanner(inputFile);
) . .
}
(Multiple Choice)
4.8/5
(48)
Which String class method will remove spaces from the beginning and the end of a string?
(Multiple Choice)
4.9/5
(33)
Which of the following statements about checked and unchecked exceptions is true?
(Multiple Choice)
4.9/5
(45)
An example of a fatal error that rarely occurs and is beyond your control is the ____.
(Multiple Choice)
4.8/5
(34)
Consider the following code snippet.
Scanner inputFile = new Scanner("dataIn.txt");
Which of the following statements is correct?
(Multiple Choice)
4.8/5
(39)
Consider the following code snippet.
PrintWriter outFile = new PrintWriter("dataOut.txt");
Which of the following statements about the PrintWriter object is correct?
(Multiple Choice)
5.0/5
(32)
Which of the following objects should be used for reading from a text file?
(Multiple Choice)
4.7/5
(33)
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.
Public static void main(String[] args) throws FileNotFoundException
{
File inputFile = ________;
Scanner in = new Scanner(inputFile);
) . .
}
(Multiple Choice)
4.8/5
(36)
Consider the following code snippet.
PrintWriter outputFile = new PrintWriter("payrollReport.txt");
Which of the following statements about the PrintWriter object is correct?
(Multiple Choice)
4.9/5
(36)
Under which condition will the PrintWriter constructor generate a FileNotFoundException?
(Multiple Choice)
4.8/5
(35)
Which of the following patterns should be used for the delimiter to read one character at a time using a Scanner object's next method?
(Multiple Choice)
4.9/5
(40)
Insert the missing code in the following code fragment. This code is intended to open a file and handle the situation where the file cannot be found.
Try
{
String filename = . . .;
Scanner in = new Scanner(new File(filename));
) . .
}
___________________
{
Exception.printStackTrace();
}
(Multiple Choice)
4.8/5
(31)
Insert the missing code in the following code fragment. This fragment is intended to read a file and write to a file.
Public static void main(String[] args) throws FileNotFoundException
{
String inputFileName = "dataIn.txt";
String outputFileName = "dataOut.txt";
File inputFile = new File(inputFileName);
Scanner in = new Scanner(inputFile);
PrintWriter out = _____________;
) . .
}
(Multiple Choice)
4.8/5
(46)
Insert the missing code in the following code fragment. This fragment is intended to allow the user to select a file to be opened.
JFileChooser chooser = new JFileChooser();
Scanner in = null;
If (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION)
{
File selectedFile = __________;
In = new Scanner(selectedFile);
) . .
}
(Multiple Choice)
4.9/5
(44)
If the current method in a program will not be able to handle an exception, what should be coded into the method?
(Multiple Choice)
4.9/5
(39)
Consider the following code snippet.
Scanner inputFile = new Scanner("hoursWorked.txt");
Which of the following statements is correct?
(Multiple Choice)
4.8/5
(23)
Consider the following code snippet:
Scanner in = new Scanner(. . .);
While (in.hasNextLine())
{
String input = in.nextLine();
System.out.println(input);
}
Which of the following statements about this code is correct?
(Multiple Choice)
4.7/5
(45)
Which of the following statements about using the PrintWriter object is correct?
(Multiple Choice)
4.8/5
(35)
Showing 41 - 60 of 100
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)