%@ include file="../../ga4.jsp" %>
AWT and Java Graphics - Quiz Explanation
AWT and Java Graphics - Quiz Explanation
The answers you selected are indicated below, along with text that explains the correct answers.
1.
What AWT class forms the basis of Java graphics?
Please select the best answer.
A.
Color
B.
Graphics
C.
Paint
The correct answer is B.
The Graphics class forms the basis of Java graphics. The Color class is used solely as a means of representing colors in graphics operations. There is no Paint class defined in the Java AWT.
2.
Which method from the Graphics class could you use to draw a square?
Please select the best answer.
A.
Use the drawRect() method.
B.
Use the drawSquare() method.
C.
Create a Square object.
The correct answer is A.
To draw a square in Java, you must use the drawRect() method and provide the same value for the width and height. There is no such method as drawSquare defined in the Graphics class, and there is no Square object defined in the Java AWT.