Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA A) public void getDatabase(Database dbase){ dbase = new Database(); dbase.connection(); dbase.operations(); dbase.close(); } The connection() method can through a DConnectionException. Write a try-catch structure

JAVA

A) public void getDatabase(Database dbase){ dbase = new Database(); dbase.connection(); dbase.operations(); dbase.close(); }

The connection() method can through a DConnectionException. Write a try-catch structure for the DConnectionExcepton. In the catch block, print the message from the DConnectionException object.

B) You realize that your Database object's close method should be called no matter what. Modify your above code to include the close() method in an appropriate manner.

C) You have written a class that includes a method that contains three catch blocks. The class will not compile and you are getting a message saying that you will never reach the code that is in the last catch block. What is the problem?

D) The method below can throw a DConnectionException. However, you have decided that you do not wish to handle the exception within the method. Instead, if an exception occurs in the method you want to have the method throw the exception object, which will be handled at a higher level than within the method itself. Modify the method so it does that. public void get Database(Database dbase){ dbase = new Database(); dbase.connection(); dbase.operations(); dbase.close(); }

E) This method is being overridden so that it will be nonfunctional. Write the code to override the method so that if called, an UnsupportedOperationException object will be created and thrown from the method.

public void assignData(Data d){ data = d; }

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

Database Horse Betting The Road To Absolute Horse Racing 2

Authors: NAKAGAWA,YUKIO

1st Edition

B0CFZN219G, 979-8856410593

More Books

Students also viewed these Databases questions

Question

Write the structure for a. dCMP b. dGMP

Answered: 1 week ago