Multiple Choice
Consider the code snippet below: public class RectangleComponent extends JComponent
{
Private Rectangle box;
Private static final int BOX_X = 100;
Private static final int BOX_Y = 100;
Private static final int BOX_WIDTH = 20;
Private static final int BOX_HEIGHT = 30;
Public RectangleComponent()
{
// The rectangle that the paint method draws
Box = new Rectangle(BOX_X, BOX_Y,
BOX_WIDTH, BOX_HEIGHT) ;
}
Public void paintComponent(GraphicsG) {
Super.paintComponent(g) ;
Graphics2D g2 = (Graphics2D) g;
G2) draw(box) ;
}
Public void moveTo(int x, int y)
{
box.setLocation(x, y) ;
Repaint() ;
}
}
Which statement causes the rectangle to appear at an updated location?
A) repaint() ;
B) g2.draw(box) ;
C) box.setLocation(x, y) ;
D) private Rectangle box;
Correct Answer:

Verified
Correct Answer:
Verified
Q1: The _ class in the javax.swing package
Q2: You have a class which extends the
Q3: Use the _ method to specify the
Q4: You have created a class named Motor
Q6: To respond to a button event, a
Q7: Use the _ method to add a
Q8: Which of the following statements about events
Q9: Consider the following declarations: public interface Displayable<br>{<br>Void
Q10: Consider the following code snippet. public interface
Q11: If you have multiple classes in your