1Z0-869 Free Dumps Study Materials
Question 21: Click the Exhibit button.
Given the GameCanvas code:
10. public void run() {
11. try {
12. Graphics g = getGraphics();
13. Image dog = Image.createImage("/dog.png");
14. Sprite s = new Sprite(dog, 98, 88);
15. s.setPosition(0,0);
16. while (gameActive) {
17. s.setFrame(0);
18. s.paint(g);
19. flushGraphics();
20. s.setFrame(1);
21. s.paint(g);
22. flushGraphics();
23. }
24. } catch (Exception ex) {
25. //...
31. }
32. }
Assuming that gameActive is true, and that run() is called as a result of a new thread's start() invocation,
what is the result?
A. An exception is thrown at runtime because of an error with the arguments to the Sprite
constructor.
B. An IndexOutOfBoundsException occurs due to an error in line 17 or line 20.
C. The dog on the left side of the image file appears on the display, but the dog on the right side is never
seen.
D. Compilation fails because Sprite does NOT have a paint(Graphics g) method.
E. An animation appears that continuously cycles between the two versions of the dog.
Correct Answer: E