Computer
Science 4
Java for Video Games
Exam 2
Sample Questions
- Covers chapters 7, 8, and 10 from the course textbook: Java Concepts (4th Edition) by Cay Horstmann
- Debugging
- Describe the difference between a syntax error and a semantic error
- Given code, hand simulate it and describe what it does
- Given code with a bug in it, explain what the bug is and how to fix it
- Collections
- Describe the difference between Java's built-in array and Java's class
ArrayList
- When would you use one instead of the other
- Write code to create a collection and add items to it
- Loops
- Describe the purpose of the four parts of a loop (initialization, test, update, and body)
- Write code for a loop that positions a collection of sprites in a pattern
- Write code for a loop that determines an extreme value within a collection (i.e., the max or min value)
- Write code for a loop that calculates a value (i.e., how many intersections, how many visible, average color, etc.)
- Games and Levels
- Explain why the method initState cannot be used directly to initialize each new level
- Given a game, describe how to determine if the game is over or the level is over
- Given a game, describe how to change some property based on different levels
- Colors
- Explain how the primary colors red, green, and blue are combined to create a single color value
- What is the range of values for the red, green, and blue components of a color
- How is a grey scale color represented
- How is a random color created
- Write code to create a range of colors that are stored in a collection
- Questions related to your assignments
- Given code for a
GeneralPath
or CAG
sprite, draw the resulting sprite that would appear on the screen
- Given a game, write code within a
Tracker
to animate its sprite