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
The PrintWriter class is an enhancement of the ____ class.
Free
(Multiple Choice)
4.8/5
(44)
Correct Answer:
C
Consider the following code snippet.
File hoursFile = new File("hoursWorked.txt");
Your program must read the contents of this file using a Scanner object. Which of the following is the correct syntax for doing this?
Free
(Multiple Choice)
4.7/5
(37)
Correct Answer:
C
Which of the following statements about command line arguments is correct?
Free
(Multiple Choice)
4.9/5
(41)
Correct Answer:
D
Consider the following code snippet:
Scanner in = new Scanner(. . .);
In)useDelimiter("[^0-9A-Za-z]+");
What characters will be ignored and not read in using this code?
(Multiple Choice)
4.9/5
(37)
Insert the missing code in the following code fragment. This fragment is intended to read binary data.
Public static void main(String[] args) throws IOException
{
String address = "http://horstmann.com/bigjava.gif";
URL imageLocation = new URL(address);
InputStream in = _________;
) . .
}
(Multiple Choice)
4.7/5
(37)
Which of the following is the correct syntax for starting a Java program named myProg from a command line if the program requires two arguments named arg1 and arg2 to be supplied?
(Multiple Choice)
4.9/5
(46)
Which of the following statements about reading web pages is true?
(Multiple Choice)
4.7/5
(35)
Consider the following code snippet:
Public static void main(String[] args) throws IOException
Which of the following statements about this code is correct?
(Multiple Choice)
4.8/5
(29)
Insert the missing code in the following code fragment. This fragment is intended to read binary data.
Public static void main(String[] args) throws IOException
{
String address = "http://horstmann.com/bigjava.gif";
URL imageLocation = _________;
InputStream in = imageLocation.openStream());
) . .
}
(Multiple Choice)
4.9/5
(35)
Consider the following code snippet:
Scanner in = new Scanner(. . .);
In)useDelimiter("[^A-Za-z]+");
What characters will be ignored and not read in when using this code?
(Multiple Choice)
4.8/5
(41)
Consider the following code snippet:
Try
{
PrintWriter outputFile = new PrintWriter(filename);
WriteData(outputFile);
}
Finally
{
OutputFile.close();
}
Catch (IOException exception)
{
) . .
}
Which of the following statements about this code is correct?
(Multiple Choice)
4.9/5
(42)
Which of the following statements about white space in Java is correct?
(Multiple Choice)
4.8/5
(29)
Consider the following code snippet:
Public void readFile(String filename) throws FileNotFoundException
{
File inFile = new File(filename);
Scanner in = new Scanner(inFile);
) . .
}
If the file cannot be located, which of the following statements about this code is correct?
(Multiple Choice)
4.8/5
(39)
You wish to use the Scanner class's nextInt() method to read in whole numbers. To avoid exceptions that would occur if the input is not a whole number, you should use the ____ method before calling nextInt.
(Multiple Choice)
4.8/5
(41)
Which of the following statements about checked and unchecked exceptions is NOT true?
(Multiple Choice)
4.9/5
(34)
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() _________________
{
File inputFile = new File(. . .);
Scanner in = new Scanner(inputFile);
Try
{
While (in.hasNext())
{
) . .
}
}
Finally
{
In)close();
}
}
(Multiple Choice)
4.7/5
(26)
Insert the missing code in the following code fragment. This fragment is intended to read an input file named hoursWorked.txt. You want the program to terminate if the file does not exist.
Public static void main(String[] args) ______________
{
File inputFile = new File("hoursWorked.txt");
Scanner in = new Scanner(inputFile);
) . .
}
(Multiple Choice)
4.7/5
(38)
When you start a Java program from a command line and supply argument values, the values ____.
(Multiple Choice)
4.9/5
(40)
Which of the following statements about exception handling is correct?
(Multiple Choice)
5.0/5
(27)
When reading words using a Scanner object's next method, ____.
(Multiple Choice)
4.9/5
(43)
Showing 1 - 20 of 100
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)