Question: 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
Get step-by-step solutions from verified subject matter experts
