还有几个月就是AP大考了,同学们都开始复习了吗?今天给同学们总结一波AP计算机考点,如果有选修AP计算机的同学,这些考点是你复习的重点哦!
Java的发展历史以及Java特性
属于了解的知识点,作为学习java语法的背景切入。主要内容:1.java的由来,java的应用开发范围和领域2. Java编程语言和其他语言的特殊之处,编程做工程的特点。
java 语言的基本数据类型
考试必考java的数据类型的分类和primitive 数据类型和non-primitive数据类型特点,以及分类依据
class 和 Object 的定义 &类和对象的特性
重点知识点,必考。主要内容:1. Class 和Object的定义 2. Class 和object的区别和联系,以及各自的特点
第四类的基本组成 以及所包含的函数类型
重点知识点,必考。主要内容:1. 一般类的两个组成部分 2.类的函数类型,以及各自的特点,特别是构造函数,定义,特点。
第五继承的定义
重点知识点,必考。主要内容:1.继承的定义和特点。此讲只讲继承的定义主要是其非常重要以及不好理解。
第六继承的特点以及继承的应用举例
重点知识点,必考。主要内容:1.继承发生的特点,哪些可以继承哪些不能继承以及继承后有什么特点必须要注意熟悉;2. 继承的应用例子解析
第七多态的概念、特点及应用举例
重点知识点,必考。主要内容:1.多态的概念,由于多态很难理解,所以定义上并没有给出什么叫多态,通过一个例子来理解什么是多态以及发生多态时的特点;2. 多态的特点
第八Java内置的一些类String,Integer,Double,Math
了解的知识点。 主要内容:1.考试大纲中要求了解,最好能熟记String,Integer,Double,Math这四个类都有哪些函数。
第九程序设计的内涵
了解的知识点。此讲主要是为了大题写程序题。讲解下写程序的一般理念和主要原则,以及注意点的得分失分点。
第十多态的概念
重点知识点,必考。主要内容:1.主要是从程序出发点讲解多态的概念。
第十一ArrayList数组类
重点知识点,必考。主要内容:1.arraylist的概念以及主要的函数;2. Arraylist的数组应用,遍历是重中之重,选择题和大题都是必考
第十二递归函数概念及原理
重点内容,选择题必考。主要内容:1.递归的概念及原理;2.递归函数的应用择题中应用注意是惯考的;
第十三算法
重点内容。主要内容:1.算法的概念;2. 4个排序函数和2个查找函数;
第十四 case study
重点内容,5-10个选择题和1个大题。主要内容:1.都有哪些actor ;2.这些actor都有哪些特殊行为;
1.Introductory Java Language Features
Package And Classes 类和包
public class FirstProg // file name is FirstProg.java
{
public static type1 method1 (parameter list)
{
<code for method1>
}
public static type2 method2 (parameter list)
{
<code for method 2>
}
......
public static void main (String[] args)
{
<your code>
}
}
All java methods must be contained in a class; all program statement must be placed in a method
The class that contains the main method does not contain many additional methods.
reserved words (Keywords): class, public, static, void, main.
public: the class or method is usable outside of the class
static: methods that will not access any objects of a class. The main method must always be static.
Types And Identifiers 标识符和类型
Identifiers 标识符
Identifier: name for a variable, parameter, constant, user-defined method, user-defined class
cannot begin with a digit
Lowercase: for variables and methods
Uppercase: separate into multiple words e.g getName, findSurfaceArea
a class name starts with a capitol letter
Built-in Types 内置类型
int - 整数
boolean - true or false
double - 小数
Storage of Numbers 数值储存
Integers 整数
binary
Integer.MAX_VALUE == 2^31-1
Integer.MIN_VALUE == - 2^31
Floating-Point Numbers 浮点数
NaN"not a number" - undefined number
float & double
sign * mantissa * 2^exponent
round-off error - when floating-point numbers are converted into binary, most cannot be represented exactly
e.g 0.1*26 ≠ 0.1+0.1......(26 terms)
Hexadecimal Numbers 十六进制数
conversion between hex and binary
5 hex = 0101 bin F hex = 1111 bin
5F hex = 01011111 bin
Final Variable Final变量
user-defined constant
keyword final
e.g. final double TAX_RATE = 0.08;
final variable can be declared without initializing it immediately, but can only be given just once
array bound
final int MAXSTUDENTS = 25;
int [] classList = new Int[MAXSTUDENTS];
Operators 运算符
Arithmetic Operators 算数运算符
+ addition - subtraction * multiplication /devision %mod(remainder)
Relational Operators 关系运算符
== equal to != not equal to > greater than < less than >= greater or equal to <= less than or equal to
Relational Operators can only be used in comparison of primitive types.
User defined types : equals, compareTo methods
floating-point should not be compared directly using relational operators.
Logical Operators 逻辑运算符
! NOT && AND || OR
Short-circuit evaluation
evaluated from left to right
evaluation automatically stops as soon as the value of the entire expression is known
Assignment Operators 赋值运算符
Compound assignment operators :
= += -= *= /= %=
Increment and Decrement Operator 递增递减运算符
++ --
Operator Precedence 运算符的优先级
!, ++ , -- right to left
* , / , % left to right
+ , - left to right
<, >, <=, >= left to right
== , != left to right
&&
||
=, +=, -+, *=, /=, %= right to left
Input/Output 输入输出
Escape sequences 转义字符
\n newline
\" double quot
\\ backslash
Control Structures 控制结构
Decision-Making Control Structures 条件结构
if...
if...else...
nested if
extended if (if...elseif...)
Iteration 循环结构
for (initialization; termination condition; update statement)
The termination condition is tested at the top of the loop
the update statement is performed at the bottom
loop variable should not have its value changed inside the loop body
the scope of the loop variable can be restricted to the loop body by combining the loop variable declaration with the initialization.
for loop
for (SomeType element : collection)
cannot be used to replace or remove elements
hides the index variable that is used with array
for-each loop
while (boolean test)
while loop
2.Classes and Objects
Public, Private, Static 公开,私有,静态
public method
accessible to all client program
private method
can be accessed only by methods of that class
information hiding
all instance variables are private
Static variable (class variable)
keep track on statics for objects of the class
accumulate a total
provide a new identity number for each new object of the class
contains a value that is shared by all instances of the class
memory allocation happens once
usage
Methods 方法
Headers
Constructors
default constructor - no arguments
creates an object of the class
name: always the same as the class
has no return type
several constructors provides different ways of initializing an object
public BankAccount ()
{
myPassword = " ";
myBalance = 0.0;
}
BankAccount b = new BankAccount ();
the constructor with parameters
public BankAccount (String password, double balance)
{
myPassword = password;
myBalance = balance;
}
BankAccount c = new BankAccount (KevinC , 800.00);
Object b and c are object variables that store the addresses of their respective BankAccount objects.
Accessors 访问器
accesses a class object without altering the object.
returns some information about the object
getSomething()
Mutator 存取器
changes the state of an object by modifying at least one of its instance variables.
setSomething()
Static Methods 静态方法
main() method
used to test other classes
all method must be static
class name . method name
object name . method name
instance methods : all methods operate on an individual objects of a class (constructors, accessors, mutators)
static methods (class methods) : methods performs an operation for the entire class
Driver Class
Method Overloading 方法重载
two or more methods in the same class having the same name but different parameter lists
signature : name & parameter types
return type is irrelevant
Scope 范围
the region where the variable or method is visible and can be accessed
within the class all instance variable and methods can be simply accessed by name (not dot operator)
local variable : defined inside a method or statement. scope: the point where it is declared to the end of the block to its declaration occurs.
when a block is excited, the memory of a local variable is automatically recycled.
this Keyword
the instance method is always called for a particular object
implicit parameter - this
References 引用
primitive data types : double, int, boolean
reference data types : all objects
Difference : the way they are stored
primitive : each has its own memory slot
reference : contains the same address
aliasing : having two reference for the same object.
The Null Reference
a uninitialized object variable is called a null reference or null pointer
statement : object == null
object = null // set to null
NullPointerException - invoke an instance method with a null reference
if you fail to initialize a local variable in a method before you use it, you will get a compile time error
if you make the same mistake with an instance variable of a class, the code may run without error
if you don't initialize a reference instance variable in a class - NullPointerException
Method Parameters
formal parameter (dummy) : placeholders for actual parameter
actual parameter (argument) : supplied by a particular method in a client program
Passing Primitive types as parameters
When a memory is called, a new memory slot is allocated for each parameter.
Any changes made to parameters will not affect the values of the arguments in the calling program.
Passing Objects as parameters
the address is copied (not the value)
not possible for a method to make an object replace another one
can change the state of the object
3.Inheritance and polymorphism
Inheritance 继承
Superclass and Subclass 超类和子类
a subclass is bigger than a superclass - it contains more methods and data
Inheritance Hierarchy 继承层次结构
a subclass can itself be a superclass of another class
subclass is-a superclass
is-a is transitive
method overriding - rewrite the method from superclass
partial overriding - part of the method is rewritten
Implementing subclasses 实现子类
keyword : extends
public class Superclass
{
// private instance variables
// other data members
// constructors
// public methods
// private methods
}
public class Subclass extends Superclass
{
// additional private instance variables
// additional data members
// constructors (not inherited!)
// additional public methods
// inherited public methods whose implementation is overridden
// additional private methods
}
Inheriting Instance Methods and Variables 继承实例方法和变量
the subclasses inherit all of the methods and variables of the superclass
instance variables are private and not directly accessible to the methods in the subclasses
classes on the same level in a hierarchy diagram do not inherit anything from each other
method overriding and the super keyword 方法重载和super关键字
include a call to the superclass method
subclass method wants to do what the superclass does, plus something extra
a method in a superclass is overridden in a subclass by defining a method with the same return typer and signature
partial overriding
constructors and super 构造函数和super
Constructors are never inherited!
the new instance variable must be explicitly initialized
if super is used in the implementation of a subclass constructor, it must be used in the first line of the constructor body.
if no constructor is provided in a subclass, the compiler provides the following default constructor
public SubClass()
{
Super(); // calls default constructor of superclass
}
Rules for Subclasses
A subclass can add new private instance variables.
A subclass can add new public, private, or static methods.
A subclass can override inherited methods.
A subclass may not redefine a public method as private.
A subclass may not override static methods of the superclass.
A subclass should define its own constructors.
A subclass cannot directly access the private members of its superclass. It must use accessor or mutator methods.
Declaring Subclass Objects 声明子类对象
Student s = new Student();
Student g = new GradStudent();
Student u = new UnderGrad();
A super class does not inherit from a subclass
Polymorphism 多态
Polymorphism is the mechanism of selecting the appropriate method of a particular object in a class hierarchy.
method calls are always determined by the type of the actual object, not the type of object reference.
the selection of the correct method occurs during the run of the program.
Dynamic Binding (Late Binding) 动态绑定(后期绑定)
overloaded - selected at compile time - static binding, early binding
overridden - selected at runtime - late binding
compiler determine if a method can be called
run-time environment determine how it will be called.
Type Compatibility 类型兼容性
Downcasting 向下转换
downcast - casting a superclass to a subclass type
Student s = new GradStudent( );
GradStudent g = new GradStudent( );
int x = s.getID( ); // compile-time error
int y = g.getID( ); // legal
s is of type Student - Student class odes not have a getID method
can be fixed by casting s to the correct type
int x = ((GradStudent) s ).getID( );
the outer parentheses are necessary
The ClassCastException
a run-time exception thrown to signal an attempt to cast an object to a class of which it is not an instance
Abstract Class 抽象类
a superclass that represents an abstract concept
may contains abstract methods - have no implementation code, just a header
appears as a place holder
If a class contains any abstract methods, it must be declared an abstract class
The abstract Keyword abstract关键字
public abstract class AbstractClass
{ ... }
public class SubClass extends AbstractClass
{ ... }
if a subclass of an abstract class does not provide implementation code for all the abstract methods, it too becomes an abstract class
public abstract class Subclass extends AbstractClass
{ ... }
An abstract class can have both instance variables and concrete methods
the header is terminated with a semicolon
It is possible for an abstract class to have no abstract methods
An abstract class may or may not have constructors
No instances can be created for an abstract class
Polymorphism works with abstract classes as it does with concrete classes
Interfaces 接口
Interface 接口
a collection of related methods whose headers are provided without implementations
all methods are public and abstract (no need to explicitly include these keywords)
provide a framework of behavior for any class
Defining an interface 定义接口
public interface FlyingObject
{
void fly(); // method that simulate the flight of the object
boolean isFlying(); // true if the object is in flight, false otherwise
}
The implements Keyword
public class Bird implements FlyingObject
public class mosquito extends Insect implements FlyingObject
The Comparable Interface
public interface Comparable
{
int compareTo (Object obj);
}
4.Some Standard Classes
The Object Class
The Universal Superclass
every class automatically extends Object
Methods in the Object
Object is NOT an abstract class
expectation : the methods will be overridden in any class where default implementation is not suitable
toString
public String toString()
when you attempt to print an object, the inherited default toString method is invokes
Array objects are unusual in that they do not have toString method
equals
public boolean equals(Object another)
return true if this object and other are the same object (referencing to the same memory slot)
equivalent to the == relation
The String Class
String Objects
a sequence of characters
immutable - no methods to change them after they've been constructed
constructing String Objects
can be initialized like a primitive type
String s = "abc"
String s = new String("abc");
it is possible to reassign a string reference
The Concatenation Operator
If one of the operands is a String and the other is a primitive type, then the non-String operand is converted to a String
If neither of the operands is a String object, an error occurs
Comparison of String Objects
overridden inherited from the Object class and overridden to do the correct thing:
equal
if (string1 .equals (string2)) ...
the String class implement Comparable
compares Strings in dictionary order
return true if string1 and string2 are identical strings
compareTo
java is case-sensitive
digits precede capital letters precede lowercase letters
Other String Methods
int length(
return the length of this String
String substring(int startIndex)
return a substring starts with the character at startIndex and extends to the end of the string
the first character is at index zero
StringIndexOutOfBoundsException if startIndex is negative or larger than the length of the string
String substring (int startIndex, int endIndex)
start at startIndex, end at endIndex-1
int indexOf(String str)
return the index of the first occurrence of str
return -1 if str is not the substring
if str is null - NullPointerException
Wrapper Classes
The Integer Class
The Double Class
5.Program Design and Analysis
The Water Fall Model 瀑布模型
Analysis of Specification 程序详细计划书
a written description based on costumer's requirements
Program Design 程序设计
detailed overall plan without Java code
include all objects + data structure + list of tasks
Implementation 程序实现
actual coding (具体接下来有)
Testing and Debugging 调试和测试
upgrading code as circumstances change
write a robust program to avoid bad input
compile-time error - occur during compilation e.g. syntax error
run-time error - occur during execution "throws an exception"
intent/ logic error - fails to carry out the specification of the program
typical values in each part of the domain
end point values
out-of-range values
Test Data 测试数据
Types of Errors (bugs) 错误类型
Robustness 稳健性
Program Maintenance 程序维护
Object-Oriented Program Design 面对对象程序设计
Identifying Classes 确定类
Basic Object
Collection
Controller
Display
Identifying Behaviors 确定行为
find all verbs in the program description
encapsulation 封装 bundling a group of methods and data fields into a class
Think carefully about who should do what
Determining Relationships Between Classes 确定类之间的关系
Inheritance Relationship 继承关系 (is-a)
Composition Relationship 组合关系 (has-a)
UML Diagrams UML图
实心箭头 has-a
空心箭头 is-a
interface 虚线
Implementing Classes 实现类
start with an over view of the program
collaborators: all other classes needed for one particular class
independent: a class without collaborators
Independent classes are written and tested before being incorporated into the overall project
Bottom-Up development自下而上开发
Top-Down development 自上而下开发
Implementing Methods 实现方法
Procedure Abstraction 过程抽象
avoid repeating code
use helper methods
Information Hiding 信息隐藏
instance variable and helper methods are private
Stub Method 存根方法
stub - a dummy method
Algorithm 算法
Identifying Classes 确定类
use nouns in the description
Relationship Between Classes 确定类之间的关系
Identifying Behaviors 确定行为
Decisions 制定
Program Analysis 程序分析
Program Correctness 程序的正确性
Assertion 验证
Precondition 前提条件
postcondition 后置条件
Efficiency 性能
CPU time (number of machine operations required)
Memory (number and complexity of the variables)
best case, worst case, average case
对于目标美国优质大学的同学来说AP成绩几乎是标配了,像哈佛、耶鲁、普林斯顿这样的学校,要求学员提供4-6门成绩。但AP毕竟是按大学要求设计的考试,对于大部分国际学校生来说还是有难度的,如果你觉得很难兼顾课堂和AP的学习,点击报名【AP冬季全程班】——
知名大学海归AP导师授课
适合所有在校学员与社会考生
启发国际课程思维
点拨应试技巧
帮助学员掌握AP灵活的出题方式
点击
不知道AP理科课程怎么学 快来听教出AP满分班的大神有什么大招
查看更多。
学习有方法,成长看得见
筑梦牛剑/G5/常春藤