Deck 11: Advanced User Interfaces

ملء الشاشة (f)
exit full mode
سؤال
When adding a component to a container with the ____ layout, specify the NORTH, EAST, SOUTH, WEST, or CENTER position.

A) border
B) grid
C) grid bag
D) flow
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
What is the default layout manager of JPanel?

A) FlowLayout
B) GridLayout
C) BoxLayout
D) GridBagLayout
سؤال
Which class has constants called NORTH and SOUTH?

A) FlowLayout
B) BorderLayout
C) BoxLayout
D) GridLayout
سؤال
By default, a JPanel uses a _______ layout.

A) border
B) flow
C) grid
D) grid bag
سؤال
Which layout manager may change the location and size of existing components when new ones are added?
I FlowLayout
II BorderLayout
III GridLayout

A) I
B) II
C) I and III
D) II and III
سؤال
Which layout manager allows you to add components to it by invoking the container's add method with the component as the only argument to add.
I FlowLayout
II BorderLayout
III GridLayout

A) I
B) II
C) III
D) I and III
سؤال
Which layout manager constructor call would be best-suited to create a telephone handset GUI which has three rows of three keys each with labels, 1,2,3,4,5,6,7,8,9, and a fourth row with labels *, 0, and #?

A) new GridLayout(3, 4)
B) new GridLayout(4, 3)
C) new FlowLayout(4, 3)
D) new BorderLayout(3, 4)
سؤال
Which layout manager uses a grid so that each component will always be placed into an area of the same size?
I GridBagLayout
II BorderLayout
III GridLayout

A) I
B) II
C) III
D) I and III
سؤال
What is the easiest way to create complex-looking GUI layouts?
I use the GridBagLayout manager
II nest panels, each with its own layout manager
III use multiple layout managers in the same container

A) I
B) II
C) III
D) I and III
سؤال
The JFrame has a content pane with a default BorderLayout manager. Which method allows changing it to a FlowLayout manager?

A) setLayout
B) setFlowLayout
C) assignLayout
D) changeLayout
سؤال
Which layout manger would be best suited to create a simple navigation GUI with directional arrows for left, right, up, down and enter?

A) GridLayout
B) BorderLayout
C) FlowLayout
D) GridBagLayout
سؤال
If you want to have a tabular arrangement of components, in which columns have different sizes or one component spans multiple columns, a ____ would be appropriate.

A) grid bag layout
B) grid layout
C) flow layout
D) border layout
سؤال
Which layout manager allows you to add components in different orders, with the result being the same GUI appearance?
I FlowLayout
II BorderLayout
III GridLayout

A) I
B) II
C) I and III
D) II and III
سؤال
To create a _____ layout, you supply the number of rows and columns in the constructor, then add the components, row by row, left to right.

A) border
B) grid
C) grid bag
D) boxed
سؤال
Which layout manager uses a grid, but allows selected grid locations to span multiple rows or columns?
I GridBagLayout
II BorderLayout
III GridLayout

A) I
B) II
C) III
D) I and III
سؤال
Which layout manager places objects left-to-right, and creates a new row only if when the current row cannot accommodate another object?

A) FlowLayout
B) BorderLayout
C) BoxLayout
D) GridLayout
سؤال
Which layout manager places objects left-to-right, row by row into a fixed set of rows and columns?

A) FlowLayout
B) BorderLayout
C) BoxLayout
D) GridLayout
سؤال
In Java, each container has its own ____________________, which determines how the components are laid out.

A) container
B) layout manager
C) Swing component
D) frame manager
سؤال
How do you add two buttons to the south area of a frame using the BorderLayout?

A) Add them to a panel, then add the panel to the SOUTH
B) Add one to the SOUTH, then add the second one to the SOUTH
C) Add one to the SOUTH, then add the second one to the CENTER
D) Add one to the CENTER, then add the second one to the SOUTH
سؤال
What is the default layout manager of the content pane of a JFrame?

A) FlowLayout
B) GridLayout
C) BoxLayout
D) BorderLayout
سؤال
Insert the missing code in the following segment. The code intends to get the newly selected item from the combo box.
JComboBox facenameCombo = new JComboBox();
String selectedString = __________________________;

A) (String) facenameCombo.getSelected();
B) (String) facenameCombo.getSelectedItem();
C) (String) selectedString.getSelected();
D) (String) selectedString.getSelectedItem();
سؤال
What type does the method getSelectedItem in the JComboBox class return?

A) Object
B) String
C) JRadioButton
D) JLabel
سؤال
The event that is generated by a slider when its value changes is of type _____.

A) ActionEvent
B) ChangeEvent
C) ItemEvent
D) MouseEvent
سؤال
Which of the following GUI objects generate(s) action events?
I JComboBox
II JRadioButton
III JButton

A) I
B) I and II
C) I and III
D) I, II and III
سؤال
When using a combo box, the _______ displays the name of the current selection.

A) text field
B) text area
C) menu item
D) submenu item
سؤال
What is the container for top-level menu items?

A) menu bar
B) menu item
C) menu GUI
D) top level menus don't use containers
سؤال
Which GUI element allows text entry from the program user?

A) ButtonGroup
B) JComboBox
C) JSlider
D) JPanel
سؤال
Which method can a program use to set the selected choice in a JRadioButton?

A) set
B) setChoice
C) setSelectedItem
D) setSelected
سؤال
Which of the following methods returns the object that was selected in the JComboBox?

A) getSelected
B) getItem
C) getChoice
D) getSelectedItem
سؤال
A(n) ____ is used when you have a large set of choices.

A) combo box
B) radio button
C) check box
D) action event
سؤال
____________________ are round and have a black dot when selected.

A) Swing components
B) Selection buttons
C) Radio buttons
D) Check boxes
سؤال
What type of object can be added into a JComboBox by the addItem method?

A) Object
B) String
C) JRadioButton
D) any non-primitive type
سؤال
A ________ is a user-interface component with two states: checked and unchecked.

A) radio button
B) check box
C) menu item
D) submenu item
سؤال
Which method can a program use to set the selected choice in a JComboBox?

A) select
B) setChoice
C) setSelectedItem
D) The selection can only be set through the GUI by the user.
سؤال
Which of the following classes has a Boolean state that can be set or unset through the GUI?

A) JCheckBox
B) JButton
C) ButtonGroup
D) JMenuItem
سؤال
The statement that would add smallButton to the button group in the following code is _________.
JRadioButton smallButton = new JRadioButton("Small");
ButtonGroup group = new ButtonGroup();

A) group.add(new smallButton);
B) group.add(smallButton);
C) smallButton.add();
D) You cannot add smallButton to the button group.
سؤال
A ____ is a combination of a list and a text field.

A) radio button
B) combo box
C) check box
D) scroll bar
سؤال
When the user selects a menu item, the menu item sends a(n) ___________________.

A) ActionEvent
B) ChangeEvent
C) ItemEvent
D) MouseEvent
سؤال
Which of the following is not a visual component?

A) JRadioButton
B) JButton
C) ButtonGroup
D) JCheckBox
سؤال
Which of the following classes have a user-editable area?

A) JCheckBox
B) JComboBox
C) ButtonGroup
D) JRadioButton
سؤال
Consider the code snippet below:
Public class RectangleComponent extends JComponent
{
Private static final int RECTANGLE_WIDTH = 20;
Private static final int RECTANGLE_HEIGHT = 30;
Private int xLeft;
Private int yTop;
Public RectangleComponent()
{
XLeft = 0;
YTop = 0;
}
Public void paintComponent(Graphics

A) repaint();
B) public void moveRectangleBy(int dx, int dy);
C) xLeft = xLeft + dx;
YTop = yTop + dy;
D) xLeft = 0;
YTop = 0;
G) {
G)fillRect(xLeft, yTop, RECTANGLE_WIDTH, RECTANGLE_HEIGHT);
}
Public void moveRectangleBy(int dx, int dy)
{
XLeft = xLeft + dx;
YTop = yTop + dy;
Repaint();
}
}
Which statement(s) causes the rectangle to appear at an updated location?
سؤال
What method is required by the ChangeListener interface?

A) changeOccured
B) actionPerformed
C) stateChanged
D) sliderMoved
سؤال
Consider the following code snippet:
Final RectangleComponent component = new RectangleComponent();
MouseListener listener = new MousePressListener();
Component.addMouseListener(listener);
______________
Mystery.add(component);
Mystery.setSize(FRAME_WIDTH, FRAME_HEIGHT);
Mystery.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Mystery.setVisible(true);
Which of the following statements completes this code?

A) JPanel mystery = new JPanel();
B) JComponent mystery = new JComponent();
C) Frame mystery = new Frame();
D) JFrame mystery = new JFrame();
سؤال
What can be determined about obj from the code below?
JMenuItem menuItem = new JMenuItem("Exit");
MenuItem.addActionListener(obj);

A) The class of obj implements ActionListener
B) menuItem implements ActionListener
C) obj is of type MenuListener
D) obj is an object of an inner class
سؤال
What is the best way to discover the set of Swing components?

A) Randomly drag them into a visual appllication with a GUI builder
B) Write code to instantiate each component one at a time
C) Read the documentation for Swing
D) Run the SwingSet demo included in the JDK, Java Development Kit
سؤال
If one ChangeListener is listening for three different JSlider objects, how can we determine which of the three sliders caused the event when the code enters the stateChanged method?

A) It is not possible.
B) We can compare the sliders using the getSource method.
C) We can call the getValueIsAdjusting method.
D) We can compare the sliders using the getSliderSource method.
سؤال
What is the best way to start using Swing components?

A) Use a few classes with basic properties and methods, then explore API documentation
B) Learn all the classes in Swing and their inheritance hierarchies
C) Learn all the methods of the JComponent superclass before using any Swing components
D) Use a Swing component only after understanding all of its constructors
سؤال
Which code will create a JSlider with a range from 0 to 100, with an initial value of 50?
I new JSlider()
II new JSlider(0, 100, 50)
III new JSlider(50, 0, 100)

A) I
B) II
C) III
D) I and II
سؤال
The ____ class in the javax.swing package generates a sequence of events, spaced apart at even time intervals.

A) TimeClock
B) Timer
C) Clock
D) StopWatch
سؤال
When you use a timer, you need to define a class that implements the ____ interface.

A) TimerListener
B) TimerActionListener
C) ActionListener
D) StartTimerListener
سؤال
Examine the code below. What type of class is MyMenuListener?
Public JMenuItem makeMenuItem(String menuLabel)
{
JMenuItem mini = new JMenuItem(menuLabel);
Class MyMenuListener implements ActionListener
{
Public void actionPerformed(ActionEvent

A) It is an anonymous class
B) It is an inner class
C) It is a JMenuItem subclass
D) It is a JMenu class
E) {
DoSomething();
}
}
Mini.addActionListener(new MyMenuListener());
Return mi;
}
سؤال
The _______ interface toolkit has a large set of user-interface components.

A) GUI Builder
B) graphical user
C) Swing
D) JMenu
سؤال
If the makeMenuItem method is called four times, at most how many different actions can be performed by these four newly created MenuItem objects when the doSomethingElse method is called?
Public JMenuItem makeMenuItem(String menuLabel)
{
JMenuItem mi = new JMenuItem(menuLabel);
Class MyMenuListener implements ActionListener
{
Public void actionPerformed(ActionEvent

A) 1
B) 2
C) 3
D) 4
E) {
DoSomethingElse(e);
}
}
Mi)addActionListener(new MyMenuListener());
Return mi;
}
سؤال
The ChangeEvent class defines no methods. What makes it possible to call the getSource method on a ChangeEvent object?

A) The method is inherited from the Object class.
B) You have to code that method yourself.
C) The method is inherited from the EventObject class.
D) ChangeEvent implements the Event interface
سؤال
What type of event does the JSlider class generate?

A) ChangeEvent
B) ActionEvent
C) ItemEvent
D) SliderEvent
سؤال
If the method makeMenuItem is called four times, how many MyMenuListener objects will be created?
Public JMenuItem makeMenuItem(String menuLabel)
{
JMenuItem mi = new JMenuItem(menuLabel);
Class MyMenuListener implements ActionListener
{
Public void actionPerformed(ActionEvent

A) 1
B) 2
C) 3
D) 4
E) {
DoSomething();
}
}
Mi)addActionListener(new MyMenuListener());
Return mi;
}
سؤال
Which component can be added to a menu?
I JMenuBar
II JMenu
III JMenuItem

A) I
B) I and II
C) II and III
D) I, II and III
سؤال
The Timer class is found in the ____ package.

A) java.awt.
B) javax.awt.
C) java.swing.
D) javax.swing.
سؤال
Which component can generate action events?
I JMenuBar
II JMenu
III JMenuItem

A) I
B) II
C) III
D) II and III
سؤال
For a new programmer using the Swing JSlider component for the first time, which of these is the least important thing to know?

A) a basic way to construct a JSlider
B) what type of events it generates
C) how to write the BoundedRangeModel constructor
D) its value when an event occurs
سؤال
Consider the following code snippet:
Class MouseClickedListener implements ActionListener
{
Public void mouseClicked(MouseEvent event)
{
Int x = event.getX();
Int y = event.getY();
Component.moveTo(x,y);
}
}
What is wrong with this code?

A) The mouseClicked method cannot access the x and y coordinates of the mouse.
B) repaint() method was not called.
C) The class has implemented the wrong interface.
D) There is nothing wrong with this code.
سؤال
What does the MouseAdapter class provide?

A) The MouseAdapter class implements all of the methods of the MouseListener interface as do nothing methods.
B) The MouseAdapter class allows your program to accept input from multiple mice.
C) The MouseAdapter class implements all of the methods of the ActionListener interface as do nothing methods.
D) A class can implement the MouseAdapter class to handle mouse events.
سؤال
Suppose listener is an instance of a class that implements the MouseListener interface. How many methods does listener have?

A) 0
B) 1
C) 3
D) at least 5
سؤال
You can add a(n) _________ to a panel to make it visible.

A) component
B) JFrame
C) border
D) another panel
سؤال
Which of the following adds a border to the following panel?
JPanel panel = new JPanel();

A) panel.addEtchedBorder();
B) panel.addBorder(new EtchedBorder());
C) panel.add(new EtchedBorder());
D) panel.setBorder(new EtchedBorder());
سؤال
You wish to detect when the mouse is moved into a graphical component. Which methods of the associated MouseListener interface will provide this information?

A) mouseMoved
B) mouseEntered
C) mouseOver
D) mouseIncoming
سؤال
Given four JRadioButton objects in a ButtonGroup, how many radio buttons can be selected at the same time?

A) 1
B) 2
C) 4
D) 3
سؤال
A(n) ____ is used to capture mouse events.

A) action listener
B) event listener
C) mouse listener
D) component listener
سؤال
When a menu item is selected, what type of event does it send?

A) ActionEvent
B) ChangeEvent
C) ItemEvent
D) SelectionEvent
سؤال
If a JPanel with a BorderLayout manager contains a single component that was added to the CENTER, which parts of the JPanel does the component fill?
I North
II South
III Center
IV West
V East

A) I, II and III
B) II, IV an V
C) III, IV and V
D) I, II, III, IV and V
سؤال
Consider the following code snippet:
Class MyListener implements ActionListener
{
Public void actionPerformed(ActionEvent event)
{
System.out.println(event);
}
}
Timer t = new Timer(interval, listener);
T)start();
What is wrong with this code?

A) The Timer object should be declared before the MyListener class.
B) The listener must be declared as new MyListener().
C) The Timer object must be declared as final.
D) The word listener should be change to MyListener.
سؤال
Suppose a JPanel with a BorderLayout manager contains two components: component1, which was added to the NORTH, and component2, which was added to the SOUTH. Which parts of the JPanel will appear?
I North
II South
III Center
IV West
V East

A) I, II and III
B) II, IV an V
C) III, IV and V
D) I, II, III, IV an V
سؤال
What is the best first step in picking the layout managers for a set of nested panels?

A) use a single panel with a GridBagLayout manager
B) construct a set of JPanel objects
C) make a sketch of the layout
D) use multiple panels with FlowLayout managers
سؤال
Suppose a JPanel with a BorderLayout manager contains two components: component1, which was added to the EAST, and component2, which was added to the WEST. Which parts of the JPanel appear?
I North
II South
III Center
IV West
V East

A) I, II
B) I, II, III
C) III, IV and V
D) IV an V
سؤال
Use the ____ method to add a mouse listener to a component.

A) addListener
B) addMouseListener
C) addActionListener
D) addMouseActionListener
سؤال
A complex GUI can be created with a set of nested panels. What should determine the components that go into a single panel?

A) the type of components
B) the size of the components
C) the adjacency of the components
D) the names of the components
سؤال
Consider the following code snippet:
Public class MyMouseListener implements MouseListener
{
Public void mousePressed(MouseEvent event)
{
Double x;
Double y;
_______
System.out.println("x: " + x + ", y: " + y);
}
) . .
}
Which of the following statements should be filled in the blank to print out where the mouse was pressed?

A) x = event.getXposition(); y = event.getYposition();
B) x = (MouseEvent) getX(); y = (MouseEvent) getY();
C) x = event.printX(); y = event.printY();
D) x = event.getX(); y = event.getY();
سؤال
What features do GUI builders have to speed the development of the graphical user interface of the program?
I setting properties of dialog boxes
II automated event-handling code generation
III drag and drop of visual components

A) I
B) II
C) II and III
D) I, II and III
سؤال
What is the most time-effective way to build a GUI quickly and concentrate on coding the logic of the program?

A) use the GridBagLayout manager
B) use a GUI builder, such as NetBeans
C) use nested panels
D) use menus
سؤال
Suppose a JPanel with a BorderLayout manager contains two components: component1, which was added to the CENTER, and component2, which was added to the SOUTH. Which parts of the JPanel will appear?
I North
II South
III Center
IV West
V East

A) I, II
B) I, II, III
C) III, IV and V
D) II and III
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/91
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 11: Advanced User Interfaces
1
When adding a component to a container with the ____ layout, specify the NORTH, EAST, SOUTH, WEST, or CENTER position.

A) border
B) grid
C) grid bag
D) flow
A
2
What is the default layout manager of JPanel?

A) FlowLayout
B) GridLayout
C) BoxLayout
D) GridBagLayout
A
3
Which class has constants called NORTH and SOUTH?

A) FlowLayout
B) BorderLayout
C) BoxLayout
D) GridLayout
B
4
By default, a JPanel uses a _______ layout.

A) border
B) flow
C) grid
D) grid bag
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
5
Which layout manager may change the location and size of existing components when new ones are added?
I FlowLayout
II BorderLayout
III GridLayout

A) I
B) II
C) I and III
D) II and III
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
6
Which layout manager allows you to add components to it by invoking the container's add method with the component as the only argument to add.
I FlowLayout
II BorderLayout
III GridLayout

A) I
B) II
C) III
D) I and III
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
7
Which layout manager constructor call would be best-suited to create a telephone handset GUI which has three rows of three keys each with labels, 1,2,3,4,5,6,7,8,9, and a fourth row with labels *, 0, and #?

A) new GridLayout(3, 4)
B) new GridLayout(4, 3)
C) new FlowLayout(4, 3)
D) new BorderLayout(3, 4)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
8
Which layout manager uses a grid so that each component will always be placed into an area of the same size?
I GridBagLayout
II BorderLayout
III GridLayout

A) I
B) II
C) III
D) I and III
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
9
What is the easiest way to create complex-looking GUI layouts?
I use the GridBagLayout manager
II nest panels, each with its own layout manager
III use multiple layout managers in the same container

A) I
B) II
C) III
D) I and III
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
10
The JFrame has a content pane with a default BorderLayout manager. Which method allows changing it to a FlowLayout manager?

A) setLayout
B) setFlowLayout
C) assignLayout
D) changeLayout
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
11
Which layout manger would be best suited to create a simple navigation GUI with directional arrows for left, right, up, down and enter?

A) GridLayout
B) BorderLayout
C) FlowLayout
D) GridBagLayout
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
12
If you want to have a tabular arrangement of components, in which columns have different sizes or one component spans multiple columns, a ____ would be appropriate.

A) grid bag layout
B) grid layout
C) flow layout
D) border layout
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
13
Which layout manager allows you to add components in different orders, with the result being the same GUI appearance?
I FlowLayout
II BorderLayout
III GridLayout

A) I
B) II
C) I and III
D) II and III
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
14
To create a _____ layout, you supply the number of rows and columns in the constructor, then add the components, row by row, left to right.

A) border
B) grid
C) grid bag
D) boxed
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
15
Which layout manager uses a grid, but allows selected grid locations to span multiple rows or columns?
I GridBagLayout
II BorderLayout
III GridLayout

A) I
B) II
C) III
D) I and III
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
16
Which layout manager places objects left-to-right, and creates a new row only if when the current row cannot accommodate another object?

A) FlowLayout
B) BorderLayout
C) BoxLayout
D) GridLayout
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
17
Which layout manager places objects left-to-right, row by row into a fixed set of rows and columns?

A) FlowLayout
B) BorderLayout
C) BoxLayout
D) GridLayout
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
18
In Java, each container has its own ____________________, which determines how the components are laid out.

A) container
B) layout manager
C) Swing component
D) frame manager
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
19
How do you add two buttons to the south area of a frame using the BorderLayout?

A) Add them to a panel, then add the panel to the SOUTH
B) Add one to the SOUTH, then add the second one to the SOUTH
C) Add one to the SOUTH, then add the second one to the CENTER
D) Add one to the CENTER, then add the second one to the SOUTH
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
20
What is the default layout manager of the content pane of a JFrame?

A) FlowLayout
B) GridLayout
C) BoxLayout
D) BorderLayout
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
21
Insert the missing code in the following segment. The code intends to get the newly selected item from the combo box.
JComboBox facenameCombo = new JComboBox();
String selectedString = __________________________;

A) (String) facenameCombo.getSelected();
B) (String) facenameCombo.getSelectedItem();
C) (String) selectedString.getSelected();
D) (String) selectedString.getSelectedItem();
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
22
What type does the method getSelectedItem in the JComboBox class return?

A) Object
B) String
C) JRadioButton
D) JLabel
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
23
The event that is generated by a slider when its value changes is of type _____.

A) ActionEvent
B) ChangeEvent
C) ItemEvent
D) MouseEvent
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
24
Which of the following GUI objects generate(s) action events?
I JComboBox
II JRadioButton
III JButton

A) I
B) I and II
C) I and III
D) I, II and III
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
25
When using a combo box, the _______ displays the name of the current selection.

A) text field
B) text area
C) menu item
D) submenu item
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
26
What is the container for top-level menu items?

A) menu bar
B) menu item
C) menu GUI
D) top level menus don't use containers
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
27
Which GUI element allows text entry from the program user?

A) ButtonGroup
B) JComboBox
C) JSlider
D) JPanel
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
28
Which method can a program use to set the selected choice in a JRadioButton?

A) set
B) setChoice
C) setSelectedItem
D) setSelected
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
29
Which of the following methods returns the object that was selected in the JComboBox?

A) getSelected
B) getItem
C) getChoice
D) getSelectedItem
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
30
A(n) ____ is used when you have a large set of choices.

A) combo box
B) radio button
C) check box
D) action event
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
31
____________________ are round and have a black dot when selected.

A) Swing components
B) Selection buttons
C) Radio buttons
D) Check boxes
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
32
What type of object can be added into a JComboBox by the addItem method?

A) Object
B) String
C) JRadioButton
D) any non-primitive type
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
33
A ________ is a user-interface component with two states: checked and unchecked.

A) radio button
B) check box
C) menu item
D) submenu item
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
34
Which method can a program use to set the selected choice in a JComboBox?

A) select
B) setChoice
C) setSelectedItem
D) The selection can only be set through the GUI by the user.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
35
Which of the following classes has a Boolean state that can be set or unset through the GUI?

A) JCheckBox
B) JButton
C) ButtonGroup
D) JMenuItem
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
36
The statement that would add smallButton to the button group in the following code is _________.
JRadioButton smallButton = new JRadioButton("Small");
ButtonGroup group = new ButtonGroup();

A) group.add(new smallButton);
B) group.add(smallButton);
C) smallButton.add();
D) You cannot add smallButton to the button group.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
37
A ____ is a combination of a list and a text field.

A) radio button
B) combo box
C) check box
D) scroll bar
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
38
When the user selects a menu item, the menu item sends a(n) ___________________.

A) ActionEvent
B) ChangeEvent
C) ItemEvent
D) MouseEvent
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
39
Which of the following is not a visual component?

A) JRadioButton
B) JButton
C) ButtonGroup
D) JCheckBox
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
40
Which of the following classes have a user-editable area?

A) JCheckBox
B) JComboBox
C) ButtonGroup
D) JRadioButton
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
41
Consider the code snippet below:
Public class RectangleComponent extends JComponent
{
Private static final int RECTANGLE_WIDTH = 20;
Private static final int RECTANGLE_HEIGHT = 30;
Private int xLeft;
Private int yTop;
Public RectangleComponent()
{
XLeft = 0;
YTop = 0;
}
Public void paintComponent(Graphics

A) repaint();
B) public void moveRectangleBy(int dx, int dy);
C) xLeft = xLeft + dx;
YTop = yTop + dy;
D) xLeft = 0;
YTop = 0;
G) {
G)fillRect(xLeft, yTop, RECTANGLE_WIDTH, RECTANGLE_HEIGHT);
}
Public void moveRectangleBy(int dx, int dy)
{
XLeft = xLeft + dx;
YTop = yTop + dy;
Repaint();
}
}
Which statement(s) causes the rectangle to appear at an updated location?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
42
What method is required by the ChangeListener interface?

A) changeOccured
B) actionPerformed
C) stateChanged
D) sliderMoved
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
43
Consider the following code snippet:
Final RectangleComponent component = new RectangleComponent();
MouseListener listener = new MousePressListener();
Component.addMouseListener(listener);
______________
Mystery.add(component);
Mystery.setSize(FRAME_WIDTH, FRAME_HEIGHT);
Mystery.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Mystery.setVisible(true);
Which of the following statements completes this code?

A) JPanel mystery = new JPanel();
B) JComponent mystery = new JComponent();
C) Frame mystery = new Frame();
D) JFrame mystery = new JFrame();
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
44
What can be determined about obj from the code below?
JMenuItem menuItem = new JMenuItem("Exit");
MenuItem.addActionListener(obj);

A) The class of obj implements ActionListener
B) menuItem implements ActionListener
C) obj is of type MenuListener
D) obj is an object of an inner class
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
45
What is the best way to discover the set of Swing components?

A) Randomly drag them into a visual appllication with a GUI builder
B) Write code to instantiate each component one at a time
C) Read the documentation for Swing
D) Run the SwingSet demo included in the JDK, Java Development Kit
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
46
If one ChangeListener is listening for three different JSlider objects, how can we determine which of the three sliders caused the event when the code enters the stateChanged method?

A) It is not possible.
B) We can compare the sliders using the getSource method.
C) We can call the getValueIsAdjusting method.
D) We can compare the sliders using the getSliderSource method.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
47
What is the best way to start using Swing components?

A) Use a few classes with basic properties and methods, then explore API documentation
B) Learn all the classes in Swing and their inheritance hierarchies
C) Learn all the methods of the JComponent superclass before using any Swing components
D) Use a Swing component only after understanding all of its constructors
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
48
Which code will create a JSlider with a range from 0 to 100, with an initial value of 50?
I new JSlider()
II new JSlider(0, 100, 50)
III new JSlider(50, 0, 100)

A) I
B) II
C) III
D) I and II
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
49
The ____ class in the javax.swing package generates a sequence of events, spaced apart at even time intervals.

A) TimeClock
B) Timer
C) Clock
D) StopWatch
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
50
When you use a timer, you need to define a class that implements the ____ interface.

A) TimerListener
B) TimerActionListener
C) ActionListener
D) StartTimerListener
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
51
Examine the code below. What type of class is MyMenuListener?
Public JMenuItem makeMenuItem(String menuLabel)
{
JMenuItem mini = new JMenuItem(menuLabel);
Class MyMenuListener implements ActionListener
{
Public void actionPerformed(ActionEvent

A) It is an anonymous class
B) It is an inner class
C) It is a JMenuItem subclass
D) It is a JMenu class
E) {
DoSomething();
}
}
Mini.addActionListener(new MyMenuListener());
Return mi;
}
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
52
The _______ interface toolkit has a large set of user-interface components.

A) GUI Builder
B) graphical user
C) Swing
D) JMenu
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
53
If the makeMenuItem method is called four times, at most how many different actions can be performed by these four newly created MenuItem objects when the doSomethingElse method is called?
Public JMenuItem makeMenuItem(String menuLabel)
{
JMenuItem mi = new JMenuItem(menuLabel);
Class MyMenuListener implements ActionListener
{
Public void actionPerformed(ActionEvent

A) 1
B) 2
C) 3
D) 4
E) {
DoSomethingElse(e);
}
}
Mi)addActionListener(new MyMenuListener());
Return mi;
}
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
54
The ChangeEvent class defines no methods. What makes it possible to call the getSource method on a ChangeEvent object?

A) The method is inherited from the Object class.
B) You have to code that method yourself.
C) The method is inherited from the EventObject class.
D) ChangeEvent implements the Event interface
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
55
What type of event does the JSlider class generate?

A) ChangeEvent
B) ActionEvent
C) ItemEvent
D) SliderEvent
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
56
If the method makeMenuItem is called four times, how many MyMenuListener objects will be created?
Public JMenuItem makeMenuItem(String menuLabel)
{
JMenuItem mi = new JMenuItem(menuLabel);
Class MyMenuListener implements ActionListener
{
Public void actionPerformed(ActionEvent

A) 1
B) 2
C) 3
D) 4
E) {
DoSomething();
}
}
Mi)addActionListener(new MyMenuListener());
Return mi;
}
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
57
Which component can be added to a menu?
I JMenuBar
II JMenu
III JMenuItem

A) I
B) I and II
C) II and III
D) I, II and III
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
58
The Timer class is found in the ____ package.

A) java.awt.
B) javax.awt.
C) java.swing.
D) javax.swing.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
59
Which component can generate action events?
I JMenuBar
II JMenu
III JMenuItem

A) I
B) II
C) III
D) II and III
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
60
For a new programmer using the Swing JSlider component for the first time, which of these is the least important thing to know?

A) a basic way to construct a JSlider
B) what type of events it generates
C) how to write the BoundedRangeModel constructor
D) its value when an event occurs
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
61
Consider the following code snippet:
Class MouseClickedListener implements ActionListener
{
Public void mouseClicked(MouseEvent event)
{
Int x = event.getX();
Int y = event.getY();
Component.moveTo(x,y);
}
}
What is wrong with this code?

A) The mouseClicked method cannot access the x and y coordinates of the mouse.
B) repaint() method was not called.
C) The class has implemented the wrong interface.
D) There is nothing wrong with this code.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
62
What does the MouseAdapter class provide?

A) The MouseAdapter class implements all of the methods of the MouseListener interface as do nothing methods.
B) The MouseAdapter class allows your program to accept input from multiple mice.
C) The MouseAdapter class implements all of the methods of the ActionListener interface as do nothing methods.
D) A class can implement the MouseAdapter class to handle mouse events.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
63
Suppose listener is an instance of a class that implements the MouseListener interface. How many methods does listener have?

A) 0
B) 1
C) 3
D) at least 5
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
64
You can add a(n) _________ to a panel to make it visible.

A) component
B) JFrame
C) border
D) another panel
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
65
Which of the following adds a border to the following panel?
JPanel panel = new JPanel();

A) panel.addEtchedBorder();
B) panel.addBorder(new EtchedBorder());
C) panel.add(new EtchedBorder());
D) panel.setBorder(new EtchedBorder());
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
66
You wish to detect when the mouse is moved into a graphical component. Which methods of the associated MouseListener interface will provide this information?

A) mouseMoved
B) mouseEntered
C) mouseOver
D) mouseIncoming
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
67
Given four JRadioButton objects in a ButtonGroup, how many radio buttons can be selected at the same time?

A) 1
B) 2
C) 4
D) 3
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
68
A(n) ____ is used to capture mouse events.

A) action listener
B) event listener
C) mouse listener
D) component listener
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
69
When a menu item is selected, what type of event does it send?

A) ActionEvent
B) ChangeEvent
C) ItemEvent
D) SelectionEvent
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
70
If a JPanel with a BorderLayout manager contains a single component that was added to the CENTER, which parts of the JPanel does the component fill?
I North
II South
III Center
IV West
V East

A) I, II and III
B) II, IV an V
C) III, IV and V
D) I, II, III, IV and V
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
71
Consider the following code snippet:
Class MyListener implements ActionListener
{
Public void actionPerformed(ActionEvent event)
{
System.out.println(event);
}
}
Timer t = new Timer(interval, listener);
T)start();
What is wrong with this code?

A) The Timer object should be declared before the MyListener class.
B) The listener must be declared as new MyListener().
C) The Timer object must be declared as final.
D) The word listener should be change to MyListener.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
72
Suppose a JPanel with a BorderLayout manager contains two components: component1, which was added to the NORTH, and component2, which was added to the SOUTH. Which parts of the JPanel will appear?
I North
II South
III Center
IV West
V East

A) I, II and III
B) II, IV an V
C) III, IV and V
D) I, II, III, IV an V
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
73
What is the best first step in picking the layout managers for a set of nested panels?

A) use a single panel with a GridBagLayout manager
B) construct a set of JPanel objects
C) make a sketch of the layout
D) use multiple panels with FlowLayout managers
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
74
Suppose a JPanel with a BorderLayout manager contains two components: component1, which was added to the EAST, and component2, which was added to the WEST. Which parts of the JPanel appear?
I North
II South
III Center
IV West
V East

A) I, II
B) I, II, III
C) III, IV and V
D) IV an V
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
75
Use the ____ method to add a mouse listener to a component.

A) addListener
B) addMouseListener
C) addActionListener
D) addMouseActionListener
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
76
A complex GUI can be created with a set of nested panels. What should determine the components that go into a single panel?

A) the type of components
B) the size of the components
C) the adjacency of the components
D) the names of the components
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
77
Consider the following code snippet:
Public class MyMouseListener implements MouseListener
{
Public void mousePressed(MouseEvent event)
{
Double x;
Double y;
_______
System.out.println("x: " + x + ", y: " + y);
}
) . .
}
Which of the following statements should be filled in the blank to print out where the mouse was pressed?

A) x = event.getXposition(); y = event.getYposition();
B) x = (MouseEvent) getX(); y = (MouseEvent) getY();
C) x = event.printX(); y = event.printY();
D) x = event.getX(); y = event.getY();
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
78
What features do GUI builders have to speed the development of the graphical user interface of the program?
I setting properties of dialog boxes
II automated event-handling code generation
III drag and drop of visual components

A) I
B) II
C) II and III
D) I, II and III
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
79
What is the most time-effective way to build a GUI quickly and concentrate on coding the logic of the program?

A) use the GridBagLayout manager
B) use a GUI builder, such as NetBeans
C) use nested panels
D) use menus
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
80
Suppose a JPanel with a BorderLayout manager contains two components: component1, which was added to the CENTER, and component2, which was added to the SOUTH. Which parts of the JPanel will appear?
I North
II South
III Center
IV West
V East

A) I, II
B) I, II, III
C) III, IV and V
D) II and III
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 91 في هذه المجموعة.