Similar presentations

2Introduction these questions are from:Y. Daniel Liang, Introduction to Java Programming, Ninth Editionthanks to Hind Zantout for locating the source and selecting appropriate questionsplease note that:some questions have multiple correct answersour exam is not based on this source of questions

4Chapter 126 Which of the following are subclasses of java.awt.Component?A. Container classesB. Swing user interface classesC. Helper classes such as Color and FontD. Layout managers

5Chapter 1212 Which of the following classes are in the java.awt package?A. ColorB. FontC. ComponentD. JFrameE. JComponent

6Chapter 1215 Analyze the following code. ... public class Test { public static void main(String[] args) { JFrame frame = new JFrame("My Frame"); frame.add(new JButton("OK")); frame.add(new JButton("Cancel")); ... } } A. Only button OK is displayed. B. Only button Cancel is displayed. C. Both button OK and button Cancel are displayed and button OK is displayed on the left side of button OK. D. Both button OK and button Cancel are displayed and button OK is displayed on the right side of button OK.

8Chapter 1220 Analyze the following code: public class Test1 extends JFrame { public Test1() { JButton jbt1 = new JButton("OK"); add(jbt1); jbt1 = new JButton("Not OK"); } public static void main(String[] args) { JFrame frame = new Test1(); ... } }A. The program displays nothing.B. The program displays a button with text OK.C. The program displays a button with text Not OK.D. The program displays a button with text OK and another button with text Not OK.

9Chapter 1221 What layout manager should you use so that every component occupies the same size in the container?A. a FlowLayoutB. a GridLayoutC. a BorderLayoutD. any layout

10Chapter 1222 What should you use to position a Button within an application Frame so that the size of the Button is NOT affected by the Frame size? A. a FlowLayout B. a GridLayout C. the center area of a BorderLayout D. the East or West area of a BorderLayout E. the North or South area of a BorderLayout

11Chapter 1226 To set a FlowLayout in panel jp, you can use the method __________.A. jp.setLayout(new FlowLayout());B. jp.setLayout(new FlowLayout(FlowLayout.CENTER));C. jp.setLayout(new FlowLayout(FlowLayout.center));D. jp.setLayout(FlowLayout

12Chapter 1227 The default layout out of a contentPane in a JFrame is __________.A. FlowLayoutB. GridLayoutC. BorderLayoutD. None

13Chapter 12 28 The default layout out of a JPanel is __________.A. FlowLayoutB. GridLayoutC. BorderLayoutD. None

25Chapter 166 Which of the following statements registers a panel object p as a listener for a button variable jbt?A. addActionListener(p);B. jbt.addActionListener(p);C. jbt.addActionEventListener(p);D. jbt.addEventListener(p);