Java Reference
In-Depth Information
Quiz
Review today's material by taking this three-question quiz.
Questions
1. What object is required before you can draw something in Java using Swing?
a. Graphics2D
b. WindowListener
c. JFrame
2. Which of the following is not a valid Java statement to create a Color object?
a. Color c1 = new Color(0F, 0F, 0F);
b. Color c2 = new Color(0, 0, 0);
c. Both are valid.
3. What does getSize().width refer to?
a. The width of the interface component's window
b. The width of the frame's window
c. The width of any graphical user interface component in Java
Answers
1. a.
2. c. Both are valid ways to create the object. You also can use hexadecimal values to
create a Color , as in this example:
Color c3 = new Color(0xFF, 0xCC, 0x66);
3. c. You can call getSize().width and getSize().height on any component in
Java.
13
Certification Practice
The following question is the kind of thing you could expect to be asked on a Java pro-
gramming certification test. Answer it without looking at today's material or using the
Java compiler to test the code.
 
Search WWH ::




Custom Search