Barron's AP Computer Science A [9th, 9 ed.] 9781506272009

5,943 859 4MB

English Pages 486 [541] Year 2020

Report DMCA / Copyright

DOWNLOAD FILE

Barron's AP Computer Science A [9th, 9 ed.]
 9781506272009

Table of contents :
Title Page
About the Author
Copyright
Contents
Barron’s Essential 5
Preface
Acknowledgments
Introduction
General Information About the Exam
How to Use This Book
Diagnostic Test
Computer Science A Section I
Computer Science A Section II
Answer Key (Section I)
Diagnostic Chart
Answers Explained
1. Strategies for Taking the Exam
The Multiple-Choice Section
What Is Tested?
Time Issues
Guessing
The Java Quick Reference
An Active Pencil
Troubleshooting—What’s Wrong with This Code?
Loop Tracing
Java Exceptions
Matrix Manipulation
Comparing Algorithms
Mechanics of Answering Questions
The Free-Response Section
What Is the Format?
What Is Tested?
What Types of Questions?
Skill Focus in Free-Response Questions
The Java Quick Reference
Time Issues
Grading the Free-Response Questions
Coding Issues
Maximizing Your Score
2. Introductory Java Language Features
Packages and Classes
Javadoc Comments
Types and Identifiers
Identifiers
Built-in Types
Storage of Numbers
Hexadecimal and Octal Numbers
Final Variables
Operators
Arithmetic Operators
Relational Operators
Logical Operators
Assignment Operators
Increment and Decrement Operators
Operator Precedence
Input/Output
Input
Output
Escape Sequences
Control Structures
Decision-Making Control Structures
Iteration
Errors and Exceptions
Multiple-Choice Questions on Introductory Java Language Features
Answer Key
Answers Explained
3. Classes and Objects
Objects
Classes
Public, Private, and Static
Methods
Headers
Types of Methods
Method Overloading
Scope
The this Keyword
References
Reference vs. Primitive Data Types
The Null Reference
Method Parameters
Multiple-Choice Questions on Classes and Objects
Answer Key
Answers Explained
4. Inheritance and Polymorphism
Inheritance
Superclass and Subclass
Inheritance Hierarchy
Implementing Subclasses
Declaring Subclass Objects
Polymorphism
Dynamic Binding (Late Binding)
Using super in a Subclass
Type Compatibility
Downcasting
Abstract Classes
Interfaces
Multiple-Choice Questions on Inheritance and Polymorphism
Answer Key
Answers Explained
5. Some Standard Classes
The Object Class
The Universal Superclass
Methods in Object
The String Class
String Objects
Constructing String Objects
The Concatenation Operator
Comparison of String Objects
Other String Methods
Wrapper Classes
The Integer Class
The Double Class
Autoboxing and Unboxing
The Math Class
Random Numbers
Multiple-Choice Questions on Some Standard Classes
Answer Key
Answers Explained
6. Program Design and Analysis
Software Development
Program Specification
Program Design
Program Implementation
Testing and Debugging
Program Maintenance
Object-Oriented Program Design
Identifying Classes
Identifying Behaviors
Determining Relationships Between Classes
UML Diagrams
Implementing Classes
Implementing Methods
Vocabulary Summary
Program Analysis
Program Correctness
Assertions
Efficiency
Multiple-Choice Questions on Program Design and Analysis
Answer Key
Answers Explained
7. Arrays and Array Lists
One-Dimensional Arrays
Initialization
Length of Array
Traversing a One-Dimensional Array
Arrays as Parameters
Array Variables in a Class
Array of Class Objects
Analyzing Array Algorithms
Array Lists
The ArrayList Class
The Methods of ArrayList
Autoboxing and Unboxing
Using ArrayList
Two-Dimensional Arrays
Declarations
Matrix as Array of Row Arrays
Processing a Two-Dimensional Array
Two-Dimensional Array as Parameter
Multiple-Choice Questions on Arrays and Array Lists
Answer Key
Answers Explained
8. Recursion
Recursive Methods
General Form of Simple Recursive Methods
Writing Recursive Methods
Analysis of Recursive Methods
Sorting Algorithms That Use Recursion
Recursive Helper Methods
Recursion in Two-Dimensional Grids
Sample Free-Response Question 1
Sample Free-Response Question 2
Multiple-Choice Questions on Recursion
Answer Key
Answers Explained
9. Sorting and Searching
Sorts: Selection and Insertion Sorts
Selection Sort
Insertion Sort
Recursive Sorts: Merge Sort and Quicksort
Merge Sort
Quicksort
Sorting Algorithms in Java
Sequential Search
Binary Search
Analysis of Binary Search
Multiple-Choice Questions on Sorting and Searching
Answer Key
Answers Explained
10. The AP Computer Science A Labs
The Magpie Lab
Special Emphasis
The Elevens Lab
Special Emphasis
The Picture Lab
Special Emphasis
Multiple-Choice Questions on the Lab Concepts
Answer Key
Answers Explained
Practice Tests
Practice Test 1
Computer Science A Section I
Computer Science A Section II
Answer Key (Section I)
Answers Explained
Practice Test 2
Computer Science A Section I
Computer Science A Section II
Answer Key (Section I)
Answers Explained
Appendix: Glossary of Useful Computer Terms

Polecaj historie