Question

Consider the following diagram: If the batchUpdate() method throws a BatchUpdateException, what is printed to the...

Consider the following diagram:

  1. If the batchUpdate() method throws a BatchUpdateException, what is printed to the console after the following code is executed?

public static void readDatabase() {
    try {
        DBClass.batchUpdate(); //throws BatchUpdateException

    } catch(SQLException) {
        System.out.println("SQLException");
    }
    System.out.println("Continue");
}

a.

“SQLException”

c.

“Continue”

b.

“BatchUpdateException”

d.

“SQLException” and “Continue”

Homework Answers

Answer #1

d)  “SQLException” and “Continue”

Explanation:
-------------
DBClass.batchUpdate(); //throws BatchUpdateException
BatchUpdateException is a subclass of SQLException
so, catch(SQLException) block will catch this exception and it's body is executed, which prints SQLException
and the code after this try-catch block will continue executing as normal, which prints Continue
hence the output to this code is 
SQLException
Continue


Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Consider a generic Stack class implemented using linked list with the following methods: public boolean isEmpty(),...
Consider a generic Stack class implemented using linked list with the following methods: public boolean isEmpty(), which returns true if and only if the stack is empty; public T pop() throws StackUnderflowException, which removes and returns the top element of the stack (if the stack is empty, it throws StackUnderflowException); public T peek() throws StackUnderflowException, which returns the top element of the stack (but does not remove it; it throws exception if stack is empty); public void push(T element), which...
Start with the code below and complete the getInt method. The method should prompt the user...
Start with the code below and complete the getInt method. The method should prompt the user to enter an integer. Scan the input the user types. If the input is not an int, throw an IOException; otherwise, return the int. In the main program, invoke the getInt method, use try-catch block to catch the IOException. import java.util.*; import java.io.*; public class ReadInteger { pubilc static void main() { // your code goes here } public static int getInt() throws IOException...
What is the minimum modification needed to make the code that follows compile? public void readData()...
What is the minimum modification needed to make the code that follows compile? public void readData() {     boolean dataNotFound = true;     if (dataNotFound) {         throw new IOException();     }     catch(IOException e) {         System.out.println("data file can't be found");     } } a. Place the if statement within a try block. b. Add a throws clause to the method declaration. c. Set dataNotFound to false. d. No modification is needed.
1) Consider the following Java program, which one of the following best describes "setFlavor"? public class...
1) Consider the following Java program, which one of the following best describes "setFlavor"? public class Food {     static int count;     private String flavor = "sweet";     Food() { count++; }     void setFlavor(String s) { flavor = s; }     String getFlavor() { return flavor; }     static public void main(String[] args) {         Food pepper = new Food();         System.out.println(pepper.getFlavor());     } } a. a class variable b. a constructor c. a local object variable d....
1) Consider the following Java program. Which statement updates the appearance of a button? import java.awt.event.*;...
1) Consider the following Java program. Which statement updates the appearance of a button? import java.awt.event.*; import javax.swing.*; public class Clicker extends JFrame implements ActionListener {     int count;     JButton button;     Clicker() {         super("Click Me");         button = new JButton(String.valueOf(count));         add(button);         button.addActionListener(this);         setSize(200,100);         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);         setVisible(true);     }     public void actionPerformed(ActionEvent e) {         count++;         button.setText(String.valueOf(count));     }     public static void main(String[] args) { new Clicker(); } } a. add(button);...
What is the output of the following code segment? public class Exception { ... static int...
What is the output of the following code segment? public class Exception { ... static int divider(int x, int y) { try { return x/y; } catch (ArrayIndexOutOfBoundsException a) { System.out.print("A"); return 1; } } static int computer(int x, int y) { try { return divider(x,y); } catch (NullPointerException b) { System.out.print("B"); } return 2; } public static void main(String args[]){ try { int i = computer (100, 0); } catch (ArithmeticException c) { System.out.print("C"); } } } ABC A...
What will be the output of the given code? using System; class MyProgram { static void...
What will be the output of the given code? using System; class MyProgram { static void Main(string[] args) { try { int a, b; b = 0; a = 5 / b; Console.WriteLine("No exception will occur."); } catch (ArithmeticException e) { Console.WriteLine("Exception occurs."); } finally { Console.WriteLine("Program is executed."); } Console.ReadLine(); } } A Program is executed. B No exception will occur. C Exception occurs. Program is executed. D No exception will occur. Program is executed.
Identify a positive value for parameter d that will cause this method to print "green", but...
Identify a positive value for parameter d that will cause this method to print "green", but not any of the other colors when executed. public static void ifelse(int d) { if (d >= 12.5) { System.out.println("blue"); } else if (d % 3 == 0) { System.out.println("yellow"); } else if (d < 10) { System.out.println("green"); } if (d > 6) { System.out.println("red"); } }
This maze project assumes that a cell is rectangular, and that there is an entrance into...
This maze project assumes that a cell is rectangular, and that there is an entrance into and an exit from the cell.  What if the entrance and the exit were closed doors and the user was to choose which door leads to the next cell?  What would be some pseudocode for this scenario? Reference source code for more information: public class Maze {   static Scanner sc = new Scanner(System.in);   // maze movements   static char myMove = '\0';   // cell position   static int...
Consider the following Java program : public static void main (string args [ ]) { int...
Consider the following Java program : public static void main (string args [ ]) { int result, x ; x = 1 ; result = 0; while (x < = 10) { if (x%2 == 0) result + = x ; + + x ; } System.out.println(result) ; } } Which of the following will be the output of the above program? A. 35 B. 30 C. 45 D. 35 2. public static void main(String args[]) { int i =...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT