exercises04-05

2
APCS Exposure Java Exercises 4.5 Date: Name: Period: 1. Which class has methods that use more parameters: the Math class or the Graphics class? graphics 2. What method is not found in an applet? Main method 3. What controls the execution sequence in an applet? Web browser 4. How is calling a method of the Math class different from calling a method in the Graphics class? For math it’s Math.sqrt and for graphics it’s g.setColor etc 5. What libraries must be imported in order to use the Graphics class? Ones with classes and methods 6. What does awt stand for? Abstract windows tools 7. What do the 4 parameters of the drawLine method of the Graphics class specify? drawLine(int x1, int y1, int x2, int y2) 8. What do the 4 parameters of the drawRect method of the Graphics class specify? drawRect(int x, int y, int width, int height) 9. What is the difference between drawRect and fillRect? DRAW RECT outlines a rect and fillrect fills it in 10. How do you create a square with the drawRect and fillRect methods? Make all sides equal 11. What do the 4 parameters of the drawOval method of the Graphics class specify? Exposure Java 2010, APCS Edition Exercises 4.5 Page 1 Updated: 06-09-10

Upload: christian-perner

Post on 07-Apr-2015

313 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Exercises04-05

APCS Exposure Java Exercises 4.5 Date:Name: Period:

1. Which class has methods that use more parameters: the Math class or the Graphics class? graphics

2. What method is not found in an applet? Main method

3. What controls the execution sequence in an applet? Web browser

4. How is calling a method of the Math class different from calling a method in the Graphics class? For math it’s Math.sqrt and for graphics it’s g.setColor etc

5. What libraries must be imported in order to use the Graphics class? Ones with classes and methods

6. What does awt stand for? Abstract windows tools

7. What do the 4 parameters of the drawLine method of the Graphics class specify? drawLine(int x1, int y1, int x2, int y2)

8. What do the 4 parameters of the drawRect method of the Graphics class specify? drawRect(int x, int y, int width, int height)

9. What is the difference between drawRect and fillRect? DRAW RECT outlines a rect and fillrect fills it in

10. How do you create a square with the drawRect and fillRect methods? Make all sides equal

11. What do the 4 parameters of the drawOval method of the Graphics class specify? drawOval(int x, int y, int width, int height)

12. What is the difference between drawOval and fillOval? Draw oval draws the outline, filloval fills it

13. How do you create a circle with the drawOval and fillOval methods? Use the parameters and the drawOval method

14. What is an arc? Part of an oval

Exposure Java 2010, APCS Edition Exercises 4.5 Page 1 Updated: 06-09-10

Page 2: Exercises04-05

15. The 1st 4 parameters of the drawArc method are the same as the drawOval method. What do the 5th and 6th parameters specify?

Int start, int degrees

16. When you use parameters incorrectly it may not always be apparent that the program has some __________ error. logic

17. Assume g is an object of the Graphics class. Print the Java command to change the graphics color to orange.

g.setColor(Color.ORANGE);

18. How many Color constants are built into Java? 12

19. In Java it is possible to create any of over 16 million different colors by combining different values of what 3 colors?

yes

20. What Graphics method is similar to System.out.println, but is used with graphics output? g.drawString

Exposure Java 2010, APCS Edition Exercises 4.5 Page 2 Updated: 06-09-10