Exam 11: Exceptions, and Input Output Operations
Exam 1: Introduction to Programming and the Java Language47 Questions
Exam 2: Programming Building Blocks- Java Basics57 Questions
Exam 3: Object-Oriented Programming, Part 1: Using Classes62 Questions
Exam 4: Introduction to Graphical Applications57 Questions
Exam 5: Flow of Control, Part 1: Selection68 Questions
Exam 6: Flow of Control, Part 2: Looping67 Questions
Exam 7: Object-Oriented Programming, Part 2: User-Defined Classes78 Questions
Exam 8: Single-Dimensional Arrays63 Questions
Exam 9: Multidimensional Arrays and the Arraylist Class62 Questions
Exam 10: Object-Oriented Programming, Part 3: Inheritance, Polymorphism, and Interfaces61 Questions
Exam 11: Exceptions, and Input Output Operations77 Questions
Exam 12: Graphical User Interfaces Using Java FX89 Questions
Exam 13: Recursion59 Questions
Exam 14: An Introduction to Data Structures69 Questions
Exam 15: Running Time Analysis56 Questions
Exam 16: RGB Colors, Decimal Conversion, Java Naming, and Random Number Generation110 Questions
Select questions type
Code that could generate an unchecked exception must be coded with a try and catch block.
Free
(True/False)
4.9/5
(33)
Correct Answer:
False
PrintWriter( File f) throws a FileNotFoundException.
Free
(True/False)
4.7/5
(45)
Correct Answer:
True
A variable declared inside a try block is still in scope after we exit that try block.
Free
(True/False)
4.9/5
(28)
Correct Answer:
False
When we read objects from a file using the readObject method, what happens when the end of the file is reached?
(Essay)
4.8/5
(38)
Java provides classes and methods to read data from a remote file (located somewhere on the Internet).
(True/False)
5.0/5
(42)
Why it is important to place the catch clause with the EOFException ahead of the catch clause with the IOException?
(Multiple Choice)
4.7/5
(30)
Which of the following methods in the Exception classes returns void?
(Multiple Choice)
4.7/5
(34)
When we open a file for writing and the file does not exist, what will happen?
(Multiple Choice)
4.9/5
(34)
You want to handle a suspected exception in your program, so you insert the following try and catch blocks. However, the program generated a compiler error. Improve this program to avoid that problem.
1
2 try
3 {
4 n = Integer.parseInt( s );
5 System.out.println( "Conversion was successful." );
6 catch ( NumberFormatException nfe )
7 System.out.println( "Sorry. incompatible data." );
8 System.out.println( "\nOutput from getMessage: \n"
9 + nfe.getMessage( ) );
10
11 System.out.println( "\nOutput from toString: \n"
12 + nfe.toString( ) );
13 System.out.println( "\nOutput from printStackTrace: " );
14 nfe.printStackTrace( );
15 }
(Essay)
4.9/5
(38)
It is preferable to place data items from a file in an ArrayList object instead of a fixed-length array when you do not know how many lines are in the file.
(True/False)
4.7/5
(44)
The filter method of the DoubleStream interface has the following API, DoubleStream filter( DoublePredicate predicate ). What is DoublePredicate?
(Multiple Choice)
4.9/5
(46)
Handling a possible illegal operation with a try and catch block will make the code run faster than handling it with a simple if/else construct.
(True/False)
4.8/5
(39)
To correct this segment, line 12 should be changed to int n = 1;.
10 public static void main( String [ ] args )
11 {
12 int n;
13 String s = JOptionPane.showInputDialog( null,
14 "Enter an integer" );
15 System.out.println( "You entered " + s );
16
17 try
18 {
19 n = Integer.parseInt( s );
20 System.out.println( "Conversion was successful." );
21 }
(True/False)
4.9/5
(37)
Melanie writes some code with the public class EmailChecker. She uses try and catch blocks to catch thrown exceptions. A user enters this email address: Javalovre@sw.com. Which of the following is a likely outcome?
(Multiple Choice)
4.8/5
(37)
Because the readObject method returns a generic object, what must the returned object be?
(Essay)
4.9/5
(42)
Which technique is often used when processing a Stream-in particular, calling several methods in order to process the data in the Stream?
(Multiple Choice)
4.9/5
(39)
Java does not allow objects to be written to or read from a file.
(True/False)
4.8/5
(33)
When an object is written to a file, transient instance variables of that object are not written to the file.
(True/False)
4.8/5
(33)
At run time, if a non-integer is entered, the call to the parseInt method will generate a(n):
(Multiple Choice)
4.9/5
(39)
Showing 1 - 20 of 77
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)