Solved

Consider the Code Snippet Below

Question 41

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

Unlock this Answer For Free Now!

View this answer and more for free by performing one of the following actions

qr-code

Scan the QR code to install the App and get 2 free unlocks

upload documents

Unlock quizzes for free by uploading documents