[ Quiz Answers | Chapter Index | Main Index ]

Quiz on Chapter 6

This page contains questions on Chapter 6 of Introduction to Programming Using Java. You should be able to answer these questions after studying that chapter. Sample answers to these questions can be found here.

Question 1:

Programs written for a graphical user interface have to deal with "events." Explain what is meant by the term event. Give at least two different examples of events, and discuss how a program might respond to those events.

Question 2:

Explain carefully what the repaint() method does.

Question 3:

Java has a standard class called JPanel. Discuss two ways in which JPanels can be used.

Question 4:

Draw the picture that will be produced by the following paintComponent() method:

public static void paintComponent(Graphics g) {
    for (int i=10; i <= 210; i = i + 50)
       for (int j = 10; j <= 210; j = j + 50)
Question 5:

Suppose you would like a panel that displays a green square inside a red circle, as illustrated. Write a paintComponent() method for the panel class that will draw the image.

(Picture of Circle in Square)

Question 6:

Java has a standard class called MouseEvent. What is the purpose of this class? What does an object of type MouseEvent do?

Question 7:

One of the main classes in Swing is the JComponent class. What is meant by a component? What are some examples?

Question 8:

What is the function of a LayoutManager in Java?

Question 9:

Consider the illustration of nested panels from the beginning of Section 6.6. What type of layout manager is being used for each of the three panels in that picture?

Question 10:

Explain how Timers are used to do animation.

Question 11:

What is a JCheckBox and how is it used?

Question 12:

How is the preferred size of a component set, and how is it used?

[ Quiz Answers | Chapter Index | Main Index ]