124k views
3 votes
Assume you have an 800 by 600 applet window and that g is an object of the Graphics class.Which of the following program segments will display the entire applet window red?

a. g.setColor(Color.red); g.drawRect(0,0,800,600);
b. g.setColor(Color.red); g.drawRect(800,600,0,0);
c. g.setColor(Color.red); g.fillRect(800,600,0,0);
d. g.setColor(Color.red); g.fillRect(0,0,800,600);
e. g.setColor(Color.red); g.drawRect(0,0,600,800);

1 Answer

4 votes

Final answer:

The correct program segment to display the entire applet window red is option d.

Step-by-step explanation:

The correct program segment to display the entire applet window red is option d.

g.setColor(Color.red); sets the color of the Graphics object to red, and g.fillRect(0,0,800,600); fills the entire applet window with the specified color.

The other options either use the wrong method (drawRect instead of fillRect), or specify incorrect coordinates that would not cover the entire window.

User Katenoox
by
7.9k points