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
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);...
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"); } }
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.
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 =...
THIS IS FOR JAVA I have to write a method for a game of Hangman. The...
THIS IS FOR JAVA I have to write a method for a game of Hangman. The word the user is trying to guess is made up of hashtags like so " ###### " If the user guesses a letter correctly then that letter is revealed on the hashtags like so "##e##e##" If the user guesses incorrectly then it increments an int variable named count " ++count; " String guessWord(String guess,String word, String pound) In this method, you compare the character(letter)...
(JAVA) Why is my toString method not printing out the last node? It will not print...
(JAVA) Why is my toString method not printing out the last node? It will not print out "A" which is for Alice. Everything else is working just fine except for this. package driver; import exception.StackException; import stack.*; public class StackDriver { public static void main(String[] args) throws Exception { StackInterface<Painting> painting = new LinkedStack <Painting>(); try { System.out.println("Peeking at top of player stack.\n" + painting.peek()); }catch (StackException e) { System.out.println(e); System.out.println("Let's double check if it's empty: " + painting.isEmpty()); }...
What is the output of the following Java program? public class Food {     static int...
What is the output of the following Java program? public class Food {     static int count;     private String flavor = "sweet";     Food() { count++; }     void setFlavor(String s) { s = flavor; }     String getFlavor() { return flavor; }     static public void main(String[] args) {         Food pepper = new Food();         pepper.setFlavor("spicy");         System.out.println(pepper.getFlavor());     } } Select one: a. sweet b. 1 c. The program does not compile. d. 2 e. spicy...
What output do we get? How do we get that output? Consider the following method :...
What output do we get? How do we get that output? Consider the following method : public static void processArray (int [] array) { int x = 0; for (int i = 0; i < array.length - 1; i++ ) { if (array [i] < array [i+1]) { System.out.println (i + 1) ;         }     } } In the left-hand column below are specific arrays of integers. Indicate in the right- hand column what value would be printed by...