Question 86

Given the code fragment:
public static void main (String [ ] args) throws IOException {
BufferedReader br = new BufferedReader (new InputStremReader
(System.in));
System.out.print ("Enter GDP: ");
//line 1
}
Which code fragment, when inserted at line 1, enables the code to read the GDP from the user?
  • Question 87

    Given the code fragment:

    What is the result?
  • Question 88

    Given the code fragment:

    Which two modifications should you make so that the code compiles successfully?
  • Question 89

    Given:
    Item table
    * ID, INTEGER: PK
    * DESCRIP, VARCHAR(100)
    * PRICE, REAL
    * QUANTITY< INTEGER
    And given the code fragment:
    9 . try {
    1 0. Connection conn = DriveManager.getConnection(dbURL, username, password);
    1 1. String query = "Select * FROM Item WHERE ID = 110";
    1 2. Statement stmt = conn.createStatement();
    1 3. ResultSet rs = stmt.executeQuery(query);
    1 4. while(rs.next()) {
    1 5. System.out.println("ID: " + rs.getInt("Id"));
    1 6. System.out.println("Description: " + rs.getString("Descrip"));
    1 7. System.out.println("Price: " + rs.getDouble("Price"));
    1 8. System.out.println(Quantity: " + rs.getInt("Quantity"));
    1 9. }
    2 0. } catch (SQLException se) {
    2 1. System.out.println("Error");
    2 2. }
    Assume that:
    The required database driver is configured in the classpath.
    The appropriate database is accessible with the dbURL, userName, and passWordexists.
    The SQL query is valid.
    What is the result?
  • Question 90

    Given:
    public final class IceCream {
    public void prepare() {}
    }
    public class Cake {
    public final void bake(int min, int temp) {}
    public void mix() {}
    }
    public class Shop {
    private Cake c = new Cake ();
    private final double discount = 0.25;
    public void makeReady () { c.bake(10, 120); }
    }
    public class Bread extends Cake {
    public void bake(int minutes, int temperature) {}
    public void addToppings() {}
    }
    Which statement is true?