Exam 11: Inputoutput and Exception Handling
Exam 1: Introduction98 Questions
Exam 2: Using Objects76 Questions
Exam 3: Implementing Classes103 Questions
Exam 4: Fundamental Data Types125 Questions
Exam 5: Decisions120 Questions
Exam 6: Loops128 Questions
Exam 7: Arrays and Array Lists118 Questions
Exam 8: Designing Classes95 Questions
Exam 9: Inheritance101 Questions
Exam 10: Interfaces85 Questions
Exam 11: Inputoutput and Exception Handling109 Questions
Exam 12: Object-Oriented Design104 Questions
Exam 13: Recursion110 Questions
Exam 14: Sorting and Searching109 Questions
Exam 15: The Java Collections Framework110 Questions
Exam 16: Basic Data Structures104 Questions
Exam 17: Tree Structures110 Questions
Exam 18: Generic Classes75 Questions
Exam 19: Graphical User Interfaces76 Questions
Exam 20: Streams and Binary Inputoutput82 Questions
Exam 21: Multithreading82 Questions
Exam 22: Internet Networking74 Questions
Exam 23: Relational Databases75 Questions
Exam 24: XML74 Questions
Exam 25: Web Applications75 Questions
Select questions type
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.8/5
(31)
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
(29)
Assuming that inputFile is a Scanner object used to read words from a text file, select an expression to complete the following code segment, which counts the number of words in the input file.
Int count = 0;
While (inputFile.hasNext())
{
String word = _______________;
Count++;
}
System.out.println(count);
(Multiple Choice)
4.7/5
(37)
Consider the following code snippet: throw new IllegalArgumentException("This operation is not allowed!");
Which of the following statements about this code is correct?
(Multiple Choice)
4.8/5
(40)
The ____ method of the Character class will indicate if a character contains white space.
(Multiple Choice)
4.9/5
(33)
Consider the following code snippet: System.out.printf("%-12s%8.2f",description,totalPrice);
Which of the following statements is correct?
(Multiple Choice)
4.9/5
(33)
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)
5.0/5
(45)
Which of the following statements about using a PrintWriter object is NOT true?
(Multiple Choice)
4.7/5
(36)
Consider the following code snippet. Scanner inputFile = new Scanner("dataIn.txt");
Which of the following statements is correct?
(Multiple Choice)
4.9/5
(46)
Which of the following statements about exception handling is correct?
(Multiple Choice)
4.9/5
(42)
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.8/5
(36)
Consider the following code snippet: throw IllegalStateException("This operation is not allowed!");
Which of the following statements about this code is correct?
(Multiple Choice)
4.8/5
(42)
Which String class method will remove spaces from the beginning and the end of a string?
(Multiple Choice)
4.9/5
(36)
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)
5.0/5
(32)
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.7/5
(31)
Which of the following code snippets about exceptions is correct?
(Multiple Choice)
4.9/5
(46)
Consider the following code snippet: try
{
File inputFile = new File(filename);
Scanner in = new Scanner(inputFile);
) . .
}
Catch (Exception
(Multiple Choice)
5.0/5
(35)
Assume that inputFile is a Scanner object used to read data from a text file which contains a series of double values. Select an expression to complete the following code segment, which reads the values and prints them in standard output, one per line, in a field 15 characters wide, with two digits after the decimal point. while (inputFile.hasNextDouble())
{
Double value = inputFile.nextDouble();
___________________________________ // statement do display double value
}
(Multiple Choice)
4.9/5
(44)
Which method of an exception object will provide information about the chain of method calls that led to the exception?
(Multiple Choice)
5.0/5
(39)
Showing 21 - 40 of 109
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)