CIS2168 TEN MINUTE TEST #2 September 14, 2010 In the case of multiple choice questions, please select the SINGLE answer that is CLOSEST to the truth. (4) 1. In the Java event model a. The SOURCE registers the LISTENER b. The LISTENER registers the SOURCE c. The EVENT registers TO the LISTENER d. The SOURCE registers the EVENT (4) 2. To make a button visible on the screen it must be a. Added to a visible container-object, e.g. JFrame b. Activated by 'addActionListener()' c. Created only, calling the constructor automatically shows the button on the screen (4) 3. Bring the following 6 steps of creating a GUI into the right order: Add components, apply layout, register listeners, show it to the world, import packages, set up top level containers 1. __________________ 4. ___________________________ 2. __________________ 5. ___________________________ 3. __________________ 6. ___________________________ (4) 4. Assume you find the line 'this.addActionListener(this)' in a correct Java class called 'MyClass'. What is a possible class definition of MyClass to make this line of code valid? a. public class MyClass extends JButton implements ActionListener b. public class MyClass extends JButton c. public class MyClass extends JFrame implements ActionListener d. public class MyClass extends JFrame (12) 5. Assume that frame is a JFrame, button is a JButton, listener is an ActionListener (1) How do I make the frame visible? [4 points] (2) How do I match the button and the listener? [4 points] (3) What code do I write in actionPerformed to display on the button the text "Off"? [4 points] (7) 6. Say something important that you remember about the Timer class.