Programming and Problem Solving with Java

(やまだぃちぅ) #1
725

b.private static classExampleClass implementsActionListener
{
public voidactionPerformed(ActionEvent event)
{
exampleValue = exampleField.getText();
exampleField.setText("");
}
}
c. exampleButton.addActionListener(exampleHandler);
d.private classExample2Class implementsActionListener
{
public voidactionPerformed(ActionEvent event)
{
exampleLabel.setText(exampleField.getText());
}
}
6.exampleField.setText("2000");
8.JLabel promptLabel;
JLabel countLabel;
JLabel averageLabel;
JTextField inField;
JButton button;
intcount;
inttotal;
12.JPanel myPanel;
myPanel = newJPanel();
myPanel.setLayout(newFlowLayout());
myPanel.add(new JLabel("one"));
myPanel.add(new JLabel("two"));
myPanel.add(new JLabel("three"));

Chapter 9 Exam Preparation Exercises


1.Use a try-catchstatement.
4.False
6.A switchexpression is the expression in a switchstatement whose value
determines which case label is selected.
A pretest loop is a loop in which the test occurs before the body of the loop. If the
loop expression is false, the loop body is not executed.
A posttest loop is a loop in which the test occurs after the loop body. The body of a
posttest loop always executes at least once.
Free download pdf