QUIZ

CHAPTER 10

Your Name:


10.1 For a GUI program to compile, we must

(a) inherit from Window
(b) inherit from Frame
(c) setVisible(true)
(d) call repaint

10.2 If we draw a circle using drawOval(300,20,50,50) in a frame 600 400 then it will be positioned

(a) towards the bottom of the frame and on the left
(b) towards the top of the frame and on the left
(c) towards the top of the frame and in the centre
(d) right in the centre

10.3 To change the font to sanserif bold we use

(a) setFont (sanserif, bold);
(b) g.setFont(Font.sanSerif, Font.Bold, size);
(c) g.setFont(new Font (Font.SanSerif, Font.BOLD, size));
(d) g.setFont(new Font ("SanSerif", Font.BOLD, size));

10.4 The default layout manager for a Java GUI application is

(a) Flow
(b) Border
(c) Flow centred
(d) no default

10.5 When running a GUI program, pressing a certain button had no effect. The reason is probably that:

(a) the button was not instantiated
(b) the button was not connected to a listener
(c) there was no handler for the button's event
(d) the button's variable had been assigned to another button

10.6 ActionListener is

(a) a method that is called by the program
(b) an interface that the program must implement
(c) a class that the program must inherit
(d) a method that calls the program when an event happens

10.7 In these two statements in the alternative to Example 10.3 (see Section 10.3) are

p.add (new Button ("Reboot"));
add("South", p);

Which of these answers is true?

(a) p could be before the add or as a parameter
(b) the first add refers to a panel and the second to a frame
(c) if we indented the second add, we would have to include p. for it.
(d) p is using border layout

10.8 A statement to request border layout would be:

(a) setLayout (BorderLayout);
(b) setLayout(new BorderLayout);
(c) setLayout (new BorderLayout());
(d) setLayout(new BorderLayout(), CENTER);

10.9 In the FlagMaker2 program (Example 10.3) how many frames are in existence at the end of the program?

(a) one
(b) three
(c) four
(d) none

10.10 The most significant difference between the awt and Swing is that

(a) Swing methods start with a J
(b) Swing methods make use of the look and feel of a particular platform
(c) Swing methods are more efficient
(d) Swing methods are implemented independently of any particular platform