Solved

Consider the Code Snippet Below: Public Class RectangleComponent Extends JComponent

Question 74

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:

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