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);...
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)...
1. you will just write your name in bytes - once in UTF8 bytes, once in...
1. you will just write your name in bytes - once in UTF8 bytes, once in UTF16 bytes. Name :Andrew Submit: 1. Your .java file 2. A screenshot showing your code ran and gave the right output. ---- /** * In this program you will write your first name in bytes in 2 different encodings. * Then convert the byte array to a String and print it out. * * TODO in lecture: show students how I google to find...
What is the output of the following Java program? interface Food {     public void printFlavor();...
What is the output of the following Java program? interface Food {     public void printFlavor(); } class Pepper implements Food {     public void printFlavor() { System.out.println("spicy"); } } public class Lunch {     public static void main(String[] args) {        Food pepper = new Pepper();         pepper.printFlavor();     } } Select one: a. spicy b. no output c. the program does not compile d. bland e. bland spicy
7.6 LAB: Exception handling to detect input String vs. Integer The given program reads a list...
7.6 LAB: Exception handling to detect input String vs. Integer The given program reads a list of single-word first names and ages (ending with -1), and outputs that list with the age incremented. The program fails and throws an exception if the second input on a line is a String rather than an Integer. At FIXME in the code, add a try/catch statement to catch java.util.InputMismatchException, and output 0 for the age. Ex: If the input is: Lee 18 Lua...
The following program creates a linked list which contains 5 links. Add a method called doubleValue()...
The following program creates a linked list which contains 5 links. Add a method called doubleValue() to the LinkedList class. The doubleValue() method must double the value of the number data field in each link. Add the required code to the main() method to call the doubleValue() method and display the revised list. public class Link { private int number; private Link next;      public Link(int x) { number = x; }    public void displayLink() { System.out.println("The number is:...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT