CIS355A Final Exam



Question 1 (4 pts)
(TCOs 1–6) The column names that are displayed in a JTable can be specified by using the _____ method of the DefaultTableModel.
Question 2 (4 pts)
(TCOs 1–6) What is the output of the code below?
double num = 56.4321;
System.out.printf(“%.2f”, 56.4321);
Question 3 (4 pts)
(TCOs 1–6) The signature of a method consists of ___
method name and parameter list.
return type
method name.
parameter list.
Question 4 (4 pts)
(TCOs 1–6) What is the representation of the third element in an array called?
Question 5 (4 pts)
(TCOs 1, 2, and 6) A key part of enabling the JVM to locate and call method main to begin the app’s execution is the _____ keyword, which indicates that main can be called without first creating an object of the class in which the method is declared.
Question 6 (4 pts)
(TCOs 1–6) Invoking _____ removes all elements in an ArrayList x.
Question 7 (4 pts)
(TCO 1, 4, and 6) The maximum number of radio buttons that can be selected within a ButtonGroup is
Question 8 (4 pts)
(TCOs 1–6) Which statements are most accurate regarding the following classes?
class A {
private int i;
protected int j;
class B extends A {
private int k;
protected int m;
An object of B contains data fields j, m.
An object of B contains data fields j, k, m.
An object of B contains data fields k, m.
An object of B contains data fields i, j, k, m.
Question 9 (4 pts)
(TCOs 1–6) Suppose ArrayList x contains two strings [Beijing, Singapore]. Which of the following methods will cause the list to become [Beijing, Chicago, Singapore]?
x.add(2, “Chicago”)
x.add(0, “Chicago”)
x.add(1, “Chicago”)
Question 10 (4 pts)
(TCOs 1, 5, and 6) The StringTokenizer method used to return the next field based on the delimiter character specified is
Question 11 (4 pts)
(TCOs 1–6) The title of a JFrame can be set by using which statement in the constructor of your class that extends JFrame?
super(“Title here”);
setFrameTitle(“Title here”);
setTitleFrame(“Title here”);
JFrame.super(“Title here”);
Question 12 (4 pts)
(TCOs 1, 5, and 6) Which type of exception occurs when creating a FileReader object for a nonexistent file?
Question 13 (4 pts)
(TCOs 1–6) What layout manager should you use so that every component occupies the same size in the container?
any layout
a FlowLayout
a BorderLayout
a GridLayout
Question 14 (4 pts)
(TCOs 1–6) The event handler (e.g., actionPerformed) is a method in
both source and listener object.
the EventObject class.
a listener object.
a source object.
Question 15 (4 pts)
(TCOs 1–6) The _____ method of JOptionPane is used to retrieve input from a user using a dialog box.
Question 16 (4 pts)
(TCOs 1, 4, and 6) A _____ component can contain one or more JMenu components.
Question 17 (4 pts)
(TCOs 1–6) Suppose you wish to provide an accessor method for a double instance variable named percent, what should the signature method be?
public static void getPercent()
public double getPercent()
public int getPercent()
public void getPercent()
Question 18 (4 pts)
(TCOs 1, 4, and 6) Each tab of a JTabbedPane is assigned an index; the first tab has an index of
Question 19 (4 pts)
(TCOs 1–6) Which statement is false?
You must code a default constructor for every class.
If a class’s constructors all require arguments and a program attempts to call a no-argument constructor to initialize an object of the class, a compilation error occurs.
A constructor can be called with no arguments only if the class does not have any constructors or if the class has a public no-argument constructor.
A constructor cannot have a return type.
Question 20 (4 pts)
(TCOs 1–6) A method that is associated with an individual object is called
an object method.
an instance method.
a class method.
a static method.
Question 21 (4 pts)
(TCOs 1, 5, and 6) If the database driver is not loaded, invoking what method of the Class class will throw a ClassNotFoundException?
Question 22 (4 pts)
(TCOs 1–6) _____ is invoked to create an object.
A method with a return type
A method with the void return type
A constructor
The main method
Question 23 (4 pts)
(TCOs 1–6) Which of the following statements is true regarding the following code assuming a proper database connection has been made and the statement object properly created?
ResultSet resultSet = statement.executeQuery(“select firstName, lastName from Student”);;
resultSet.getString(1) returns the lastName field in the result set.
If the SQL SELECT statement returns no result, resultSet is null.
resultSet.getString(1) returns the firstName field in the result set.
The program will have a runtime error, because data from resultSet objects must always be retrieved in a loop.
Question 24 (4 pts)
(TCOs 1–6) Suppose that your program accesses a MySQL database. Which of the following statements is false?
If the database is not available, the program will have a runtime error when attempting to create a connection object.
If the driver for MySQL database is not in the classpath, the program will have a runtime error, indicating that the driver class cannot be loaded.
If the driver for MySQL database is not in the classpath, the program will have a syntax error.
If the database connection cannot be made, a SQLException occurs.
Question 25 (4 pts)
(TCOs 1–6) Suppose a prepared statement is created as follows.
PreparedStatement ps = conn.prepareStatement
(“insert into Student (fName, mi, lName) values (?, ?, ?)”);
To assign the value John to the first parameter of this query, use
ps.setString(1, “John”);.
ps.set (1, “John”);.
ps.setString(0, “John”);.
ps.set (0, “John”);.
Question 26 (4 pts)
(TCOs 1–6) Which of the following statements is used to create an object to write to a file named out.dat?
BufferedWriter outfile = new BufferedWriter(FileWriter(“out.dat”));
BufferedWriter outfile = new BufferedWriter (new File(“out.dat”));
BufferedWriter outfile = new BufferedWriter (new FileWriter(“out.dat”));
BufferedWriter outfile = new BufferedWriter (“out.dat”);
Question 27 (4 pts)
(TCOs 1–6) Which statement is used to create a file object that will append data to an existing file?
BufferedWriter salesdata =
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 28 (4 pts)
(TCOs 1–6) What happens if the file test.dat does not exist when you attempt to compile and run the following code?
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”);
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 29 (4 pts)
(TCOs 1–6) Result set meta data are retrieved through
a Statement object.
a Connection object.
a ResultSet object.
a PreparedStatement object.
Question 30 (4 pts)
(TCOs 1–6) Clicking a JCheckBox object generates _____ events.
Question 31 (4 pts)
(TCOs 1–6) The method _____ gets the contents of the text field txtName.
Question 32 (4 pts)
(TCOs 1–6) The method _____ adds a text area jta to a scrollpane jScrollPane.
None of them.
Question 33 (4 pts)
(TCOs 1–6) Which of the following statements is false?
You can create a text field with a specified text.
You can disable editing on a text field.
You can specify the number of rows in a text field
You can specify the number of columns in a text field.
Question 34 (4 pts)
(TCOs 1–6) The item that is clicked in a JList can be retrieved using the _____ method of JList.
Question 35 (4 pts)
(TCOs 1–6) The _____ method of a radio button returns true if that button is “on”.
Question 36 (20 pts)
(TCOs 1—6) TicketsRUs needs an application to calculate ticket prices. There are three ticket prices:
Orchestra $85 each
Mezzanine $70 each
Balcony $45 each
There is also a 15% discount on matinee performances.
Your application has the GUI shown below.
With the following named components:
Clicking the CalcPrice button should determine the price per ticket and the total price based on the user’s input and display in txtEach and txtTotal. You should make sure the number of tickets is entered and a ticket type is selected, otherwise give an error message.
The action listener for btnCalc is set up as follows.
btnCalc.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
calcPrice(); //write the code for this method
Write the calcPrice method that is called by the action listener. This class method has access to all of the GUI components. You DO NOT HAVE TO CODE THE GUI. ONLY write the code for this method which does all the work. The header for the method is:
private void calcPrice()
Question 37 (20 pts)
(TCOs 1–6) Employees at a certain company get a yearly bonus based on years of service. The bonus is a percentage of their annual salary based on the table below.
Years of Service
Bonus Percentage
< 5 3% 5 – 14 7% 15++ 12% Create a class called Employee that can be used for this. It should have attributes of Name; Years; and Salary. Create the following methods. Default constructor to initialize all attributes Get/Set for name, years, salary Get to calculate and return bonus rate Get to calculate and return bonus amount This class will be used with the Bonus Calculator GUI shown below. With the following named components: Component, Type, Purpose You DO NOT have to code the GUI. The action listener for btnCalc is set up as follows. btnCalc.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { calcBonus(); //write the code for this method } }); Question 38 (15 pts) (TCOs 1–6) A trucking company has an application to track data from their trucks regarding miles driven and fuel used each month. This information is stored in a file named “trucks.txt” . This table has the following fields. TruckID Truck Number (String) Format of file – note the # delimiter character between fields TruckID#miles#fuel The application has a button that is clicked to read each line of the file and calculates and displays in the console the total miles driven, total fuel used, and average miles per gallon. You DO NOT have to write a separate class to process the data. The output in the console should look like: Total miles driven by all trucks xxx Total gallons of fuel used yyy Average miles per gallon for the fleet zz.zz The class method readFile() is called by the action listener to do the work. Write the code for this method. Question 39 (15 pts) (TCOs 1–6) Assume a College database has a table to keep transcript data on students. The transcript table has fields for SSN, TotalPoints, and TotalCredits. You are to design an application that allows a student to input their SSN into a textbox (txtSSN) and press a button (btnCalc). The students GPA is calculated (divide points by credits) and displayed in txtGPA. Describe the process/steps to do this. Write pseudocode/comments or code where you can. You DO NOT have to have complete working code, you need to describe the necessary steps and WHERE things need to be coded. SCREENSHOTS SOLUTION PAYMENT The solution includes a single word file. Attachments [Move over files to preview content of those files] (290.68 KB) CIS355A Final Exam Solution.docx Price: $19 Buy Now Checkout Added to cart Add to Cart Checkout Added to cart You May Also Like: CIS355A Final Exam Multiple Choice Questions CIS355A Final Exam Essay Questions CIS355A Week 1 Lab Developing an OOP Console Application CIS355A Week 2 Lab Developing a GUI Application CIS355A Week 3 Lab BurgersRUs Point of Sale system CIS355A Week 4 Course Project Flooring Application Analysis and Design CIS355A Week 4 Lab Stocks4U Portfolio Management System CIS355A Week 5 Lab File Processing Stocks4U Portfolio Management System CIS355A Week 6 Lab Student Management System CIS355A Week 7 Course Project Flooring Application User Manual and Application Code


There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.