Second AP* Edition — with GridWorld
Object-Oriented Programming and Data Structures
Answers and Solutions to Exercises
(for students )
Maria Litvin
Phillips Academy, Andover, Massachusetts
Gary Litvin
Skylight Software, Inc.
Skylight Publishing Andover, Massachusetts
*AP
and the Advanced Placement are registered trademarks of the College Entrance Examination Board; their use does not constitute endorsement of this material by the College Board.
Skylight Publishing 9 Bartlet Street, Suite 70 Andover, MA 01810 (978) 475-1431 e-mail: support@skylit.com web: http://www.skylit.com
Copyright © 2011 by Maria Litvin and Gary Litvin All rights reserved. Teachers who purchased Java Methods are allowed to make one copy. However, we ask you not to do this to help keep answers and solutions confidential. No part of this material may be reproduced for any other purpose without a prior written permission of the authors.
Contents
Chapter 1 Chapter 2 Chapter 3 Chapter 4 Chapter 5 Chapter 6 Chapter 7 Chapter 8 Chapter 9 Chapter 10 Chapter 11 Chapter 12 Chapter 13 Chapter 14 Chapter 15 Chapter 16 Chapter 17 Chapter 18 Chapter 19 Chapter 20 Chapter 21 Chapter 22 Chapter 23 Chapter 24 Chapter 25 Chapter 26 Chapter 27 An Introduction to Hardware, Software, and the Internet An Introduction to Software Development Objects and Classes Algorithms Java Syntax and Style Data Types, Variables, and Arithmetic Boolean Expressions and if-else Statements Iterative Statements: while, for, do–while Implementing Classes and Using Objects Strings Class Hierarchies and Interfaces Arrays java.util.ArrayList Searching and Sorting Streams and Files Graphics GUI Components and Events Mouse, Keyboard, Sounds, and Images Big-O Analysis of Algorithms The Java Collections Framework Lists and Iterators Stacks and Queues Recursion Revisited Binary Trees Lookup Tables and Hashing Heaps and Priority Queues Design Patterns
4
JAVA METHODS ANSWERS AND