Solved

Consider the Code Snippet Below

Question 12

Multiple Choice

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:

verifed

Verified

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions