Exam 12: Exceptions and Advanced File Io
Exam 1: Introduction to Computers and Java42 Questions
Exam 2: Java Fundamentals53 Questions
Exam 3: Decision Structures52 Questions
Exam 4: Loops and Files48 Questions
Exam 5: Methods50 Questions
Exam 6: A First Look at Classes49 Questions
Exam 7: A First Look at Gui Applications49 Questions
Exam 8: Arrays and the Arraylist Class52 Questions
Exam 9: A Second Look at Classes and Objects40 Questions
Exam 10: Text Processing and More About Wrapper Classes49 Questions
Exam 11: Inheritance49 Questions
Exam 12: Exceptions and Advanced File Io46 Questions
Exam 13: Advanced Gui Applications46 Questions
Exam 14: Applets and More39 Questions
Exam 15: Recursion34 Questions
Exam 16: Sorting, Searching, and Algorithm Analysis46 Questions
Exam 17: Generics50 Questions
Exam 18: Collections50 Questions
Exam 19: Array-Based Lists20 Questions
Exam 20: Linked Lists36 Questions
Exam 21: Stacks and Queues36 Questions
Exam 22: Binary Trees, Avl Trees, and Priority Queues45 Questions
Select questions type
If a random access file contains a stream of characters,which of the following would you use to set the pointer on the fifth character?
Free
(Multiple Choice)
4.8/5
(40)
Correct Answer:
D
If,within one try statement you want to have catch clauses that catch exceptions of the following types,in which order should they appear in your program? (1)Throwable
(2)Exception
(3)RuntimeException
(4)NumberFormatException
Free
(Multiple Choice)
4.8/5
(35)
Correct Answer:
A
In the following code,assume that inputFile references a Scanner object that has been successfully used to open a file: double totalIncome = 0.0;
While (inputFile.hasNext())
{
Try
{
TotalIncome += inputFile.nextDouble();
}
Catch(InputMismatchException e)
{
System.out.println("Non-numeric data encountered " +
"in the file.");
InputFile.nextLine();
}
Finally
{
TotalIncome = 35.5;
}
}
What will be the value of totalIncome after the following values are read from the file?
2)5
8)5
3)0
5)5
Abc
1)0
Free
(Multiple Choice)
4.9/5
(42)
Correct Answer:
C
In a catch statement,what does the following code do? System.out.println(e.getMessage());
(Multiple Choice)
5.0/5
(28)
If a method does not handle a possible checked exception,what must the method have?
(Multiple Choice)
5.0/5
(33)
This is a section of code that gracefully responds to exceptions when they are thrown.
(Multiple Choice)
4.9/5
(35)
The IllegalArgumentException class extends the RuntimeException class,and is therefore
(Multiple Choice)
4.7/5
(24)
Why does the following code cause a compiler error? try
{
Number = Integer.parseInt(str);
}
Catch (IllegalArgumentException e)
{
System.out.println("Bad number format.");
}
Catch (NumberFormatException e)
{
System.out.println(str + " is not a number.");
}
(Multiple Choice)
4.9/5
(39)
When writing a string to a binary file or reading a string from a binary file,it is recommended that you use
(Multiple Choice)
4.9/5
(36)
When an exception is thrown by code in the try block,the JVM begins searching the try statement for a catch clause that can handle it and passes control of the program to
(Multiple Choice)
4.9/5
(33)
When an object is serialized,it is converted into a series of bytes that contain the object's
data.
(True/False)
4.9/5
(33)
The throw statement informs the compiler that a method throws one or more exception.
(True/False)
4.9/5
(32)
A(n)________ is an object that is generated in memory as the result of an error or an unexpected event.
(Multiple Choice)
4.9/5
(38)
When deserializing an object using the readObject method,you must cast the return value to the desired class type.
(True/False)
4.8/5
(31)
What will be the result of the following code? FileOutputStream fstream new FileOutputStream("Output.dat");
DataOutputStream outputFile = new DataOutputStream(fstream);
(Multiple Choice)
4.8/5
(34)
The call stack is an internal list of all the methods that are currently executing.
(True/False)
4.7/5
(38)
Given the following constructor code,which of the statements are true? public Book(String ISBNOfBook,double priceOfBook,
Int numberOrderedOfBook)
{
If (ISBNOfBook == "")
Throw new BlankISBN();
If (priceOfBook < 0)
Throw new NegativePrice(priceOfBook);
If (numberedOrderedOfBook < 0)
Throw new NegativeNumberOrdered(numberOrderedv);
ISBN = ISBNOfBook;
Price = priceOfBook;
NumberedOrdered = numberOrderedOfBook;
}
(Multiple Choice)
5.0/5
(32)
What will the following code display? String input = "99#7";
Int number;
Try
{
Number = Integer.parseInt(input);
}
Catch(NumberFormatException ex)
{
Number = 0;
}
Catch(RuntimeException ex)
{
Number = 1;
}
Catch(Exception ex)
{
Number = -1;
}
System.out.println(number);
(Multiple Choice)
4.9/5
(38)
Showing 1 - 20 of 46
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)