Include:

Class Info
Grade Level
Other Information
Custom Fields
Public Notes
Reflection
Date(s)
Multiple Days
Structure
Purpose
Minutes
Common Core Standards
Reading and Writing

Language Features

Grade Level:
12
Subject:
AP Computer Science
Topic:
Chapter Goals
• Packages and classes
• Types and identifiers
• Operators
• Input/output
• Storage of numbers
• Binary and hexadecimal
numbers
• Control structures
• Errors and exceptions
Objective:
TheandAPtheComtechniqputueser Scienceand mecourthodsseofincludesmodernalgorprogitrhmamming,analysis,specificalldata stry,ucturobject-es,
oriented programming. A high-level programming language is used to explore these
concepts. Java is the language currently in use on the AP exam.
Java was developed by James Gosling and a team at Sun Microsystems in California; it continues to evolve. The AP exam covers a clearly defined subset of Java language features that are presented throughout this book, including some new features
of Java 5.0 that were tested for the first time in May 2007. The College Board website,
http://www.collegeboard.com/student/testing/ap/subjects.html, contains a complete listing of this subset.
Java provides basic control structures such as the if-else statement, for loop, and
while loop, as well as fundamental built-in data types. But the power of the language
lies in the manipulation of user-defined types called objects, many of which can interact
in a single program.
PACKAGES AND CLASSES
A typical Java program has user-defined classes whose objects interact with those from
Java class libraries. In Java, related classes are grouped into packages, many of which
are provided with the compiler. You can put your own classes into a package—this
facilitates their use in other programs.
115
116 Chapter 1 Introductory Java Language Features
The package java.lang, which contains many commonly used classes, is automatically provided to all Java programs. To use any other package in a program, an import
statement must be used. To import all of the classes in a package called packagename,
use the form
import packagename.*;
To import a single class called ClassName from the package, use
import packagename.ClassName;
Java has a hierarchy of packages and subpackages. Subpackages are selected using
multiple dots:
import packagename.subpackagename. ClassName;
The import statement allows the programmer to use the objects and methods defined in the designated package. By convention Java package names are lowercase. The
AP exam does not require knowledge of packages. You will not be expected to write
any import statements.
A Java program must have at least one class, the one that contains the main method.
The java files that comprise your program are called source files.
A compiler converts source code into machine-readable form called bytecode.
Here is a typical source file for a Java program.
/* Program FirstProg.java
Start with a comment, giving the prog
Prep:
None entered.
Materials:
None entered.