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

1. In order to handle an event from a JRadioButton object button1, what does a p

ID: 3538271 • Letter: 1

Question

1. In order to handle an event from a JRadioButton object button1, what does a programmer need to do?          

A.Create a nested inner class that implements the ItemListener interface.

B.Create an object of the nested inner class as the event handler object.

C.Invoke the addItemListener method on button1 to register the event handler object with the event source.

D.All OF the Above

4. To draw a rectangle with only its sides shown with the color orange, you would         

A.set the color to orange on the graphics object, and then use the fillRect method to draw the rectangle.

B.use the fillRect method to draw the rectangle, and then set the color to orange on the graphics object.

C.set the color to orange on the graphics object, and then use the drawRect method to draw the rectangle.

D.use the drawRect method to draw the rectangle, and then set the color to orange on the graphics object.

6.A class that extends the KeyAdapter class would likely

A.override one or two of the KeyListener methods provided by KeyAdapter.

B. also implement the KeyListener interface to handle KeyEvents.

C.would let the KeyAdapter handle all KeyEvents.

D.would not be interested in dealing with events from the keyboard.

7. Where does code need to be to handle a specific exception type?    

A.In a catch block.

B.In a try block.

C.In a finally block.

D.In any of these blocks.

9. The purpose of the try block is to           

A.catch an exception.

B.provide a place to put code that could fail.

C.release any resources acquired in the try block whether an exception occurs or not.

D.execute when an object is no longer needed.

10. What happens when the following code executes if myfile.txt does not exist, and you have permission to read and write the directory where myfile.txt was supposed to be?

                                        A. ObjectInputStream stream = new ObjectInputStream(new FileInputStream(%u201Cmyfile.txt%u201D));
                                        BObjectOutputStream stream = new ObjectOutputStream(new FileOutputStream(%u201Cmyfile.txt%u201D));
                                        C ObjectIOStream stream = new ObjectIOStream(new FileInputStream(%u201Cmyfile.txt%u201D));
                                        D. objectIOStream stream = new ObjectIOStream(new FileOutputStream(%u201Cmyfile.txt%u201D));

11.             Which of the following creates a data stream for writing primitive data type values to a file? (Points : 6)

     A. DataValueStream stream = new DataValueStream(new FileInputStream(%u201Cmyfile.txt%u201D));
      B. DataOutputStream stream = new DataOutputStream(new FileOutputStream(%u201Cmyfile.txt%u201D));
      C. DataInputStream stream = new DataInputStream(new FileInputStream(%u201Cmyfile.txt%u201D));
     D. DataValueStream stream = new DataValueStream(new FileOutputStream(%u201Cmyfile.txt%u201D));

14.Which of the following commands create Javadoc output which includes author and version information, and places the HTML files into a directory called documentation,

A.javadoc %u2013author %u2013version %u2013d documentation *.class

B.javadoc %u2013d documentation *.java

C.javadoc %u2013version %u2013author %u2013d documentation *.java

D. None of the above.

Explanation / Answer

1-d

4-d

6-b

7-a

9-c

10-a

11-b

14-c