Consider the code snippet below:
Public class RectangleComponent extends JComponent
{
Private static final int RECTANGLE_WIDTH = 20;
Private static final int RECTANGLE_HEIGHT = 30;
Private int xLeft;
Private int yTop;
Public RectangleComponent()
{
xLeft = 0;
yTop = 0;
}
Public void paintComponent(Graphics g) {
g.fillRect(xLeft, yTop, RECTANGLE_WIDTH, RECTANGLE_HEIGHT) ;
}
Public void moveRectangleBy(int dx, int dy)
{
xLeft = xLeft + dx;
yTop = yTop + dy;
repaint() ;
}
}
Which statement(s) causes the rectangle to appear at an updated location?
A) repaint() ;
B) public void moveRectangleBy(int dx, int dy) ;
C) xLeft = xLeft + dx;
YTop = yTop + dy;
D) xLeft = 0;
yTop = 0;
Correct Answer:
Verified
Q23: Which of the following classes have a
Q32: The statement that would add smallButton to
Q35: Which of the following is not a
Q37: A _ is a combination of a
Q43: Consider the following code snippet:
Final RectangleComponent component
Q47: If one ChangeListener is listening for three
Q50: What is the best way to discover
Q57: When the user selects a menu item,
Q57: What can be determined about obj from
Q65: What method is required by the ChangeListener
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents