117k views
1 vote
Assume you have an 800 by 600 applet window and that g is an object of the Graphics class. Which of the following will display one single pixel?

a. g.drawPixel(100,200);
b. g.drawLine(100,200,100,200);
c. Both A and B
d. Neither A, nor B

1 Answer

4 votes

Final answer:

To draw a single pixel using a Graphics object in Java, you should use the drawLine method with identical starting and ending points.

Step-by-step explanation:

The correct answer to which of the following commands will display one single pixel in an 800 by 600 applet window with a Graphics object g is: b. g.drawLine(100,200,100,200);

In Java graphics programming, there is no method drawPixel. Therefore, option A is incorrect. The correct way to draw a single pixel on the screen would be to use the drawLine method with the same starting and ending points. This will draw a line with zero length, which effectively is a single pixel.

User Mohammed Essehemy
by
8.7k points