⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mockcert06.txt

📁 一道JAVA方面的试题 很不错的 我很喜欢
💻 TXT
📖 第 1 页 / 共 5 页
字号:
 8.     Button b = new Button("Where am I?");
 9.     Panel p1 = new Panel();
10.     p1.setLayout(
11.       new FlowLayout(FlowLayout.LEFT));
12.     Panel p2 = new Panel();
13.     p2.setLayout(new BorderLayout());
14.     Panel p3 = new Panel();
15.     p3.setLayout(new GridLayout(3, 2));
16.
17.     p1.add(b);
18.     p2.add(p1, BorderLayout.NORTH);
19.     p3.add(p2);
20.     add(p3);
21.   }
22.
23.   public static void main(String args[]) {
24.     Q6 that = new Q6();
25.     that.setVisible(true);
26.   }
27. }

Only One: 
1) The button is just wide enough and tall enough to encompass its label.
2) The button is just wide enough to encompass its label; its height is the entire height of the frame.
3) The button is just tall enough to encompass its label; its width is the entire width of the frame.
4) The button is just wide enough to encompass its label, and its height is approximately half the frame's height.
5) The button's height is approximately half the frame's height. Its width is approximately half the frame's width.


Question 82
===========================================================
An application has a frame that uses a Border layout manager. Why is it probably not a good idea to put a vertical scroll bar at North in the frame?

Only One: 
1) The scroll bar's height would be its preferred height, which is not likely to be high enough.
2) The scroll bar's width would be the entire width of the frame, which would be much wider than necessary.
3) Both A and B.
4) Neither A nor B. There is no problem with the layout as described.


Question 83
===========================================================
What is the default layout manager for an applet?

Only One: 
1) FlowLayout
2) BorderLayout
3) GridLayout
4) GridBagLayout


Question 84
===========================================================
True or false: If a frame uses a Grid layout manager and does not contain any panels or other containers, then all the components within the frame are the same width and height.

Only One: 
1) True
2) False


Question 85
===========================================================
True or false: If a frame uses its default layout manager and does not contain any panels, then all the components within the frame are the same width and height.

Only One: 
1) True
2) False


Question 86
===========================================================
True or false: With a Border layout manager, the component at Center gets all the space that is left over, after the components at North and South have been considered.

Only One: 
1) True
2) False


Question 87
===========================================================
True or false: With a Grid layout manager, the preferred width of each component is honored, while height is dictated; if there are too many components to fit in a single row, additional rows are created.

Only One: 
1) True
2) False


Question 88
===========================================================
Which layout manager or managers lays components so only one is visible at a time.

Mutiple: 
1) Flow
2) Border
3) Grid
4) GridBag
5) Card


Question 89
===========================================================
Which layout manager or managers is organized as rows and columns where those rows and columns are of potentially unequal sizes.

Mutiple: 
1) Flow
2) Border
3) Grid
4) GridBag
5) Card


Question 90
===========================================================
Which layout manager or managers can simulate at least two other layout managers.

Mutiple: 
1) Flow
2) Border
3) Grid
4) GridBag
5) Card


Question 91
===========================================================
True or false: The event delegation model, introduced in release 1.1 of the JDK, is fully compatible with the 1.0 event model.

Only One: 
1) True
2) False


Question 92
===========================================================
Which statement or statements are true about the code listed below?

1. public class MyTextArea extends TextArea {
2.   public MyTextArea(int nrows, int ncols) {
3.     enableEvents(AWTEvent.TEXT_EVENT_MASK);
4.   }
5.
6.   public void processTextEvent(TextEvent te) {
7.     System.out.println("Processing a text event.");
8.   }
9. }

Mutiple: 
1) The source code should appear in a file called MyTextArea.java.
2) Between lines 2 and 3, a call should be made to super(nrows, ncols) so that the new component will have the correct size.
3) At line 6, the return type of processTextEvent() should be declared boolean, not void.
4) Between lines 7 and 8, the following code should appear: return true;
5) Between lines 7 and 8, the following code should appear: super.processTextEvent(te);


Question 93
===========================================================
Which statement or statements are true about the code listed below?

 1. public class MyFrame extends Frame {
 2.   public MyFrame(String title) {
 3.     super(title);
 4.     enableEvents(AWTEvent.WINDOW_EVENT_MASK);
 5.   }
 6.
 7.   public void processWindowEvent(WindowEvent e) {
 8.     System.out.println(
 9.         "Processing a window event.");
10.   }
11. }

Mutiple: 
1) Adding a Window listener to an instance of MyFrame will result in a compiler error.
2) Adding a Window listener to an instance of MyFrame will result in the throwing of an exception at runtime.
3) Adding a Window listener to an instance of MyFrame will result in code that compiles cleanly and executes without throwing an exception.
4) A Window listener added to an instance of MyFrame will never receive notification of Window events.


Question 94
===========================================================
Which statement or statements are true about the code fragment listed below? (Assume that classes F1 and F2 both implement the FocusListener interface.)

1. TextField tf = new TextField("Not tricky");
2. FocusListener flis1 = new F1();
3. FocusListener flis2 = new F2();
4. tf.addFocusListener(flis1);
5. tf.addFocusListener(flis2);

Mutiple: 
1) Lines 2 and 3 generate compiler errors.
2) Line 5 throws an exception at runtime.
3) The code compiles cleanly and executes without throwing an exception.


Question 95
===========================================================
Which statement or statements are true about the code fragment listed below? (Assume that classes F1 and F2 both implement the FocusListener interface.)

1. TextField tf = new TextField("Not tricky");
2. FocusListener flis1 = new F1();
3. FocusListener flis2 = new F2();
4. tf.addFocusListener(flis1);
5. tf.addFocusListener(flis2);
6. tf.removeFocusListener(flis1);

Mutiple: 
1) Lines 2 and 3 generate compiler errors.
2) Line 6 generates a compiler error.
3) Line 5 throws an exception at runtime.
4) Line 6 throws an exception at runtime.
5) The code compiles cleanly and executes without throwing an exception.


Question 96
===========================================================
Which statement or statements are true about the code fragment listed below?

1. class MyListener
2. extends MouseAdapter implements MouseListener {
3.   public void mouseEntered(MouseEvent mev) {
4.     System.out.println("Mouse entered.");
5.   }
6. }

Mutiple: 
1) The code compiles without error and defines a class that could be used as a Mouse listener.
2) The code will not compile correctly, because the class does not provide all the methods of the MouseListener interface.
3) The code compiles without error. The words implements MouseListener can be removed from line 2 without affecting the code's behavior in any way.
4) The code compiles without error. During execution, an exception will be thrown if a component uses this class as a Mouse listener and receives a mouse-exited event


Question 97
===========================================================
Which statement or statements are true about the code fragment listed below? (Hint: The ActionListener and ItemListener interfaces each define a single method.)

 1. class MyListener implements
 2.   ActionListener, ItemListener {
 3.   public void actionPerformed(ActionEvent ae) {
 4.     System.out.println("Action.");
 5.   }
 6.
 7.   public void itemStateChanged(ItemEvent ie) {
 8.     System.out.println("Item");
 9.   }
10. }

Mutiple: 
1) The code compiles without error and defines a class that could be used as an Action listener or as an Item listener.
2) The code generates a compiler error on line 2.
3) The code generates a compiler error on line 7.


Question 98
===========================================================
Which statement or statements are true about the code fragment listed below?

1. class MyListener extends MouseAdapter, KeyAdapter {
2.   public void mouseClicked(MouseEvent mev) {
3.     System.out.println("Mouse clicked.");
4.   }
5.
6.   public void keyPressed(KeyEvent kev) {
7.     System.out.println("KeyPressed.");
8.   }
9. }

Mutiple: 
1) The code compiles without error and defines a class that could be used as a Mouse listener or as a Key listener.
2) The code generates a compiler error on line 1.
3) The code generates a compiler error on line 6.


Question 99
===========================================================
A component subclass that has executed enableEvents() to enable processing of a certain kind of event cannot also use an adapter as a listener for the same kind of event.

Only One: 
1) True
2) False


Question 100
===========================================================
Assume that the class AcLis implements the ActionListener interface. The code fragment below constructs a button and gives it four Action listeners. When the button is pressed, which Action listener is the first to get its actionPerformed() method invoked?

 1. Button btn = new Button("Hello");
 2. AcLis a1 = new AcLis();
 3. AcLis a2 = new AcLis();
 4. AcLis a3 = new AcLis();
 5. AcLis a4 = new AcLis();
 6. btn.addActionListener(a1);
 7. btn.addActionListener(a2);
 8. btn.addActionListener(a3);
 9. btn.addActionListener(a4);
10. btn.removeActionListener(a2);
11. btn.removeActionListener(a3);
12. btn.addActionListener(a3);
13. btn.addActionListener(a2);

Only One: 
1) a1 gets its actionPerformed() method invoked first.
2) a2 gets its actionPerformed() method invoked first.
3) a3 gets its actionPerformed() method invoked first.
4) a4 gets its actionPerformed() method invoked first.
5) It is impossible to know which listener will be first.


Question 101
===========================================================
A text field is constructed and then given a foreground color of white and a 64-point bold serif font. The text field is then added to an applet that has a foreground color of red, background color of blue, and 7-point plain sans-serif font. Which one statement below is true about the text field?

Only One: 
1) Foreground color is black, background color is white, font is 64-point bold serif.
2) Foreground color is red, background color is blue, font is 64-point bold serif.
3) Foreground color is red, background color is blue, font is 7-point bold serif.
4) Foreground color is white, background color is blue, font is 7-point bold serif.
5) Foreground color is white, background color is blue, font is 64-point bold serif.


Question 102
===========================================================
You have a check box in a panel; the panel is in an applet. The applet contains no other components. Using setFont(), you give the applet a 100-point font, and you give the panel a 6-point font. Which statement or statements below are correct?

Mutiple: 
1) The check box uses a 12-point font.
2) The check box uses a 6-point font.
3) The check box uses a 100-point font.
4) The check box uses the applet's font, because you can't set a font on a panel.
5) he check box uses the panel's font, because you did not explicitly set a font for the check box.


Question 103
===========================================================
You have a check box in a panel; the panel is in an applet. The applet contains no other components. Using setFont(), you give the applet a 100-point font. Which statement or statements below are correct?

Mutiple: 
1) The check box uses a 12-point font.
2) The check box uses a 6-point font.
3) The check box uses a 100-point font.
4) The check box uses the applet's font.
5) The check box uses the panel's font, because you did not explicitly set a font for the check box.


Question 104
===========================================================
You want to construct a text area that is 80 character-widths wide and 10 character-heights tall. What code do you use?

Only One: 
1) new TextArea(80, 10)
2) new TextArea(10, 80)


Question 105
===========================================================
You construct a list by calling new List(10, false). Which statement or statements below are correct? (Assume that layout managers do not modify the list in any way.)

Mutiple: 
1) The list has 10 items.
2) The list supports multiple selection.
3) The list has up to 10 visible items.
4) The list does not support multiple selection.
5) The list will acquire a vertical scroll bar if needed.


Question 106
===========================================================
A text field has a variable-width font. It is constructed by calling new TextField("iiiii"). What happens if you change the contents of the text field to "wwwww"? (Bear in mind that i is one of the narrowest characters, and w is one of the widest.)

Only One: 
1) The text field becomes wider.
2) The text field becomes narrower.
3) The text field stays the same width; to see the entire contents you will have to scroll by using the -> and - keys.
4) The text field stays the same width; to see the entire contents you will have to scroll by using the text field's horizontal scroll bar.


Question 107
===========================================================
Which of the following may a menu contain? (Choose all that apply.)

Mutiple: 
1) A separator
2) A Checkbox
3) A Menu
4) A Button
5) A Panel


Question 108
===========================================================
Which of the following may contain a MenuBar? (Choose all that apply.)

Mutiple: 
1) A Panel
2) A Frame
3) An Applet
4) A MenuBar


Question 109
===========================================================
Your application constructs a frame by calling Frame f = new Frame();, but when you run the code, the frame does not appear on the screen. What code will make the frame appear? (Choose one.)

Only One: 
1) f.setSize(3

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -