Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 5: Java locates the code that handles an exception by searching through the ________________. Question 6: What happens if a FileNotFoundException occurs in the

Question 5:

Java locates the code that handles an exception by searching through the ________________.

Question 6:

What happens if a FileNotFoundException occurs in the code that follows? try (BufferedReader file = new BufferedReader(new FileReader(fileName))) { validName = true; } catch(FileNotFoundException e) { System.err.println("FileNotFoundException"); } catch(IOException e) { System.out.println("IOException"); }

a.

FileNotFoundException is printed to the console and the BufferedReader and FileReader objects are closed

b.

FileNotFoundException is printed to the console and the BufferedReader and FileReader objects are left open

c.

FileNotFoundException and IOException are printed to the console, and the BufferedReader and RileReader objects are left open

d.

FileNotFoundException and IOException are printed to the console, and the BufferedReader and RileReader objects are closed

Question 19:

The try-with-resources statement doesnt need a finally clause because it

a.

implements the AutoCloseable interface

b.

catches all exceptions that are thrown when you try to close a resource

c.

uses a multi-catch block to catch all exceptions

d.

automatically closes all declared resources

Question 22:

Exception chaining lets you

a.

save the details of an exception when a custom exception is thrown in response to that exception

b.

keep a log of the exceptions that occur as an application executes

c.

pass an exception up to the calling method

d.

handle more than one exception in the same method

Question 30:

To keep from losing debugging information when you throw a custom exception, you should use a feature called ____________________.

Question 34:

An instance of which of the following classes can be used as an argument in the method definition that follows? public void writeToFile(DataOutput out) ...

a.

DataOutput

b.

DataOutputStream

c.

OutputStream

d.

FileOutputStream

Question 36:

Code example 16-2 public static void connectAndOpenDB() { try { StudentDB.connect(); //can throw a ClassNotFoundException StudentDB.open(); //can throw an SQLException } catch(ClassNotFoundException | SQLException e) { System.out.println(e.getMessage()); } System.out.println("Connected and opened."); }

(Refer to code example 16-2.) If a method named setUp() contains only one statement that calls the connectAndOpenDB() method, what is the shortest possible declaration of that method?

a.

void setUp() throws ClassNotFoundException {...}

b.

void setUp() throws SQLException {...}

c.

void setUp() {...}

d.

void setUp() throws SQLException, ClassNotFoundException {...}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Management Systems

Authors: Mark L. Gillenson

2nd Edition

0470624701, 978-0470624708

More Books

Students also viewed these Databases questions

Question

What is database?

Answered: 1 week ago

Question

What are Mergers ?

Answered: 1 week ago