Your Name:
11.1 Reading a String value s from a Textfield t is done with (a) s = t.readString(); (b) s = readString(t); (c) s = t.getText(); (d) t.getText(s);
11.2 If the Traffic program, if there is to be a new light with a green arrow on it, what statement(s) would be needed to add it to the GUI display, without activating it? (a) buttons.add(walkButton); (b) walkButton = new Button("Walk"); buttons.add(walkButton); (c) walkButton = new Button("Walk"); (d) buttons.add (new Button("Walk"));
11.3 The best way to control the sequence in which events on certain components occur is to (a) set all but the required component invisible (b) set all but the required component disabled (c) define boolean variables which are set and checked at appropriate points (d) put each of the components in a separate panel 11.4 What event is caused by typing into a TextField? (a) TextEvent (b) ActionEvent (c) FieldEvent (d) MouseClickedEvent
11.5 What is the method used in ActionPerformed to decide what kind of event has occurred? (a) getEvent() (b) getSource() (c) getText() (d) getAction()
11.6 An event, in Java terms, is (a) an object (b) a class (c) a variable (d) a component
11.7 When a new Frame is constructed, it appears on the screen (a) immediately (b) when setVisible(true) is executed (c) at the end of the constuctor (d) whenever the paint method is executed
11.8 A statement such as closeButton.addActionListener(this) can best be interpreted as meaning: store a reference to the current object with closeButton so that an ActionEvent on closeButton will activate the actionPerformed method in the current object store a reference to the current object with amountField so that the ActionListener will be called when closeButton is pushed store a reference to closeButton with the actionListener so that close Button's event handler can be called when it is pushed store a reference to closeButton with the the current object so that the ActionListener can call this object's event handler when closeButton is pushed
11.9 We did not need a hash table in the converter program because the data were stored instead in (a) an array (b) the Swing components (c) the file (d) a linked list
11.10 In the Till program, to turn a selected product button green when it is pushed, we would use: (a) itemButtons[select].setBackground(green); (b) itemButtons[i].setBackground(green); (c) (Color.green) itemButtons[select]; (d) itemButtons[select].setBackground(Color.green);
javagently third edition, © 2001 All rights reserved, J. Bishop home | examples | downloads | discussion | preface | contents | errata | quiz | answers | faq | books | material | message | users