Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Question 1. 1. (TCOs 1, 5, and 6) What must you make available to your applicati

ID: 3822928 • Letter: Q

Question

Question 1. 1. (TCOs 1, 5, and 6) What must you make available to your application before you can use JDBC to connect to a database? (Points : 4) A database driver A web server A firewall An ODBC data source Question 2. 2. (TCOs 1–6) _____ represents an entity in the real world that can be distinctly identified. (Points : 4) A class An object A data field A method Question 3. 3. (TCOs 1–6) To execute the query "select * from Address" using the Statement object named stmt that has been properly configured with a database connection, use (Points : 4) stmt.executeUpdate("select * from Address");. stmt.execute("select * from Address");. stmt.executeQuery("select * from Address");. stmt.query("select * from Address");. Question 4. 4. (TCOs 1–6) What is the return value from the following? stmt.executeUpdate("insert into T values (100, 'Smith')"); (Points : 4) An int value indicating how many rows are effected from the invocation An object that contains the status of the execution A value indicating whether the SQL statement has been executed successfully Void Question 5. 5. (TCOs 1–6) Invoking Class.forName method when the database driver has not been configured into the project may throw (Points : 4) ClassNotFoundException. IOException. SQLException. RuntimeException. Question 6. 6. (TCOs 1–6) Which method can be used to read a whole line from a file opened with the BufferedReader object infile? (Points : 4) infile.nextLine() infile.readNext() infile.readLine() readLine(infile) Question 7. 7. (TCOs 1–6) Which statement is used to create a file object that will append data to an existing file? BufferedWriter salesdata = (Points : 4) new BufferedWriter(new FileWriter("out.dat", false);. new BufferedWriter(new FileWriter("out.dat", true);. new BufferedWriter(new FileWriter("out.dat");. new BufferedWriter(new FileWriter("out.dat", append);. Question 8. 8. (TCOs 1–6) What happens if the file test.dat does not exist when you attempt to compile and run the following code? import java.io.*; class Test { public static void main(String[ ] args) { try { BufferedReader infile = new BufferedReader(new FileReader("test.dat")); String mytext = infile.readLine(); } catch(IOException ex) { System.out.println("IO exception"); } } } (Points : 4) The program compiles, but throws IOException because the file test.dat doesn't exist. The program displays IO exception. The program does not compile because infile is not created correctly. The program does not compile because readLine() is not implemented in BufferedReader. The program compiles and runs fine, but nothing is displayed on the console. Question 9. 9. (TCOs 1–6) What information may be obtained from a ResultSetMetaData object? (Points : 4) Number of columns in the result set Database URL and product name Number of rows in the result set JDBC driver name and version Question 10. 10. (TCOs 1–6) Which of the following statements is false? (Points : 4) All the methods in JRadioButton are inherited from javax.swing.AbstractButton. You can use an icon on JRadioButton. JButton and JRadioButton fire same types of events. All the methods in JRadioButton are also in JButton. Question 11. 11. (TCOs 1–6) _____ can be used to enter or display a string. (Points : 4) A button A check box A text field A label Question 12. 12. (TCOs 1–6) To wrap a line in a text area jta, invoke (Points : 4) jta.setLineWrap(false). jta.setLineWrap(true). jta.wrapText(). jta.WrapLine(). Question 13. 13. (TCOs 1–6) The method _____ assigns the name Result to the Text of the label lblMsg. (Points : 4) lblMsg.findText() lblMsg.text("Result") lblMsg.setText("Result") lblMsg.newText("Result") Question 14. 14. (TCOs 1–6) A JList object can be populated with data stored in a(n) _____ object. (Points : 4) ModelList DefaultListModel ListArray DefaultModelList Question 15. 15. (TCOs 1–6) The _____ method of a check box returns true if that button is “checked”. (Points : 4) isSelected() getSelected() Selected() isChecked()

Explanation / Answer

1.1.

Since before JDBC there was ODBC API to connect to the database. Thus, there should be an ODBC data source before the connection of the JDBC to the database.

Thus, option d an ODBC data source is correct.

2.2.

An object is an entity in the real world with different states and behaviors. Example: A snake is an object and it has states like its color and its breed. Behavior properties of a snake includes hissing, reptiles, and biting.

An object can be distinctly identified by its states and behaviours.

Thus, option b an object is correct.

3.3.

The statement object stmt has various methods to perform query operations. The method executeQuery() returns the one object of result set and the method executeUpdate() returns an integer representing the number of rows affected. The method executeUpdate() can be used with operations like insert, delete, and update.

The method executeQuery() is used to execute an query expression.

Thus, option c stmt.executeQuery(“select * from Address”); is correct.

4.4.

The stmt.executeUpdate() is a function to update the rows of a table in a database. The number of modified rows is the return value of this function.

Thus, option a is correct.

5.5.

The Class.forName is a method that returns the object of the class with the desired name. The class is loaded from class loader. If the class with the desired name is not found, then this method throws an exception “ClassNotFoundException”.

Thus, option a ClassNotFoundException is correct.

6.6.

The readLine() method of the buffered reader class returns the content of a line. A line is considered a sterminated if a “ ” or “ ” is encountered. The readLine() method will read a whole line.

Thus, option c infile.readLine() is correct.

7.7.

The syntax to create a file object to append the data into an existing file is as follows:

BufferedWriter salesdata = new BufferedWriter(new FileWriter(“out.dat”, true));

Since option 2 is matched with the above syntax. Thus, option b is correct.

8.8.

Since the test.dat file does not exist. Thus, program will throw an IOException. If the code would not be written in the try/catch block, then the program does not compile because the file test.dat does not exist. This program uses try/catch block and handles the IOException in the catch block. The program displays the IO exception on the console.

Thus, option a is correct.

9.9.

The information about the type and properties of the column is provided by the method ResultSetMetaData.The ResultSetMetaData class has various methods to access the information about the columns.

Thus, option a is correct.

10.10.

jButton and jRadioButton perform different operations. jButton is a simple type of button while jRadioButton is a type of button in which only one nutton can be checked at a time. Both performs on different type of event listners.

Thus, option c is correct choice.

11.11.

A text field is used to enter and display the string. String entered in the text field is simultaneously visible to the users.

Thus, option c text field is correct.

12.12.

The line in a text area jta could be wrapped by the following method:

Jta.setLineWrap(true);

The method setLineWrap is used to wrap a line in a text area. Set the argument of the setLineWrap method true to wrap the line in the text area.

Thus, option b jta.setLineWrap(true) is correct.

13.13.

The method setText of the label class is used to set the name of the label. The method setText will assign the name “Result” to the label lblMsg.

Thus, option c lblMsg.setText(“Result”); is correct.

14.14.

A list array contains the array of the list items and a jList object can be populated by using the list array. The items of the list array will go to the jList constructor one by one and jList object is populated with the items of the list array.

Thus, option c ListArray is correct.

15.15.

The checkbox class has various methods to perform operations on checkbox. The isChecked() method determines that whether a checkbox is checked or not. The isChecked() method returns true if the button is checked or else return false.

The syntax of the method isChecked() is as follows:

CheckBox check=new CheckBox();

Value = check.isChecked();

Thus, option d isChecked() is correct.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote