ExamOverview

advertisement
AP CS Exam Overview
Barbara Ericson
ericson@cc.gatech.edu
March 2005
Georgia Institute of Technology
Learning Goals
• Understand the AP CS Exam
– What are the details of the exam?
– How is the exam graded?
– What is on the exam?
– Tips for taking the exam
– Resources to use in studying for the exam
Georgia Institute of Technology
Exam Details
• Two Sections (3 hour exam)
– 40 Multiple choice questions (1 hour 15 min)
•
•
•
•
•
5 answers to each question (a – e)
Only one right answer
At least 5 questions on the case study
A Topics: oo, Java basics, cs terms, testing, design decisions
AB Topics: data structures, big-O, and more design
– Free-response questions (1 hour 45 min)
• 4 questions (2-3 parts)
• One question on the case study
• A Topics: arrays, strings, classes, interfaces, sorting,
searching, Java library classes, design
• AB Topics: 2-d arrays, data structures
Georgia Institute of Technology
How the Exam is Graded
• Total score is
– score = multipleChoiceWeight * (# correctAnswers –
0.25 * #wrongAnswers) + freeResponseWeight *
freeResponseScore
• Equal weight to multiple choice and free response sections
• Each free response question is worth 9 points (partial credit
can be given)
• Free response questions are graded according to a grading
standard (rubric) by high school and college teachers
Georgia Institute of Technology
Final Grade Calculation (1999)
A
Max score 80
(1.00 * MC + 1.1111 * FR)
Composite
Score
AP Grade
AB
Max Score 100
(1.25 * MC + 1.3889 * FR)
Composite
Score
AP Grade
60-80
5
70-100
5
45-59
4
60-69
4
33-44
3
41-59
3
25-32
2
31-40
2
0-24
1
0-30
1
Georgia Institute of Technology
Exam Hints
• Read the question before reading the code
• Do the easiest questions first
• If you read the question and have ruled out a couple of
answers guess the answer
• Don’t write tricky, non-standard code
• If a question has parts answer the parts you can
• Don’t cross out what you have if you don’t add anything
new
• Write neatly and indent properly
• Follow Java conventions for names and use good names
• Don’t worry about imports or comments
• Don’t forget the return statement
• Check and follow the pre and post conditions
Georgia Institute of Technology
A and AB Topics
• See the Topic Outline
– http://apcentral.collegeboard.com/members/article/1,3
046,151-165-0-18431,00.html
• Summary Table of Language Features
– http://apcentral.collegeboard.com/members/article/1,3
046,151-165-0-18431,00.html
• A Quick Reference Guide
– http://apcentral.collegeboard.com/members/article/1,3
046,151-165-0-21170,00.html
• AB Quick Reference Guide
– http://apcentral.collegeboard.com/members/article/1,3
046,151-165-0-21169,00.html
Georgia Institute of Technology
Primitive Variables vs Object Variables
• Primitive variables are
like sliders
– Allocates space for the
variable value
– The value can be between
a min and max based on
the amount of space
• Object variables are like
a ticket to an event
ref
– Help you find your seat
Georgia Institute of Technology
Object Variables
• Remember that declaring an object
variable declares a reference to an object
of that type
– It doesn’t create the object
• Example
– String s; // declares a reference
– s.length(); // throws a null pointer exception
– s = “Hello”; // now it references a string
Georgia Institute of Technology
Inheritance versus Association
• “is a” versus “has a”
• Use inheritance when the child is really “a kind of” the
parent
– A SlowFish “is a kind of” Fish
– A Truck “is a kind of” Vehicle
• Don’t use inheritance when the child can’t be substituted
for the parent
– A Wall isn’t a kind of Fish
– A Vehicle isn’t a kind of Person
• Use “has a” when one object has an object of another
class associated with it
– A Vehicle “has a” person associated with it (the owner)
– A course session “has a” course associated with it
Georgia Institute of Technology
Inheritance Test
• Which is correct?
– A high school is a kind of school?
– An exam is a kind of question?
– A marching band is a kind of school?
– A dictionary is a kind of book?
– A cat is a kind of animal?
• You must be able to substitute the child for
the parent
– If I need a book will a dictionary do?
– If I need a school will a marching band do?
Georgia Institute of Technology
Inheritance
• You can call inherited public methods
directly
• You can access inherited public fields
directly
• You can access inherited private methods
indirectly
– Through public methods
• You can access inherited private fields
indirectly
– Through public accessors and modifiers
Georgia Institute of Technology
Inheritance Example
public class ContactInfo
{
private String name;
private String phoneNumber;
public ContactInfo(String theName, String thePhoneNumber)
{
this.name = theName;
this.phoneNumber = thePhoneNumber;
}
public String getName() { return name; }
public String getPhoneNumber() { return phoneNumber; }
}
Georgia Institute of Technology
Inheritance Example - continued
public class ExtendedContactInfo extends ContactInfo
{
private String nickname;
public ExtendedContactInfo (String nickname,
String name,
String phoneNumber)
{
// missing code
}
}
Georgia Institute of Technology
Inheritance Example - continued
• What can go in place of // missing code?
– super(theName,thePhoneNumber);
this.nickname = theNickname;
– this.name = theName; this.phoneNumber =
thePhoneNumber; this.nickname =
theNickname;
– this.nickname = theNickname;
super(theName, thePhoneNumber);
– this.nickname = theNickname; this.name =
theName; this.phoneNumber =
thePhoneNumber;
Georgia Institute of Technology
Inheritance
• The child class extends the parent class
– public class ChildClass extends ParentClass
• No extends means extends Object
• Objects of the child class inherit all the
fields and methods of the parent class
– But can’t directly access private fields or
methods
• Use public accessors and modifiers
– Can invoke parent constructor to initialize
• Use super(paramList) as first line in constructor
• If none found, one will be provided (no-arg)
Georgia Institute of Technology
Interfaces
• An interface is a way two classes can communicate
without worrying about what class each one is.
– Just need to know the methods
• Let’s you plug in different classes
– As long as they implement the interface
• Interfaces can only have abstract methods and
constants in them
• Declare an interface with
– public interface Name
• A class can implement more than one interface
– public class Name extends Parent implements Interface1,
Interface2, …
• One interface can inherit from another
– Actionable inherits from Drawable in the revised case study
Georgia Institute of Technology
Explaining Interfaces
• First point out what happens when you
hardcode a class
– Like in MBCS with Fish
• Then show how interfaces let you add new
classes
– Like Wall in the revised MBCS
Georgia Institute of Technology
Polymorphism
• Ability to call a method based on the type
of the object the method
• In Java usually refers to inheritance-based
– Method is based on parent class
• All objects have a reference to their class
– All objects know what class they are
• All methods are invoked by checking with
the class of the object first
– No matter what it is declared as
Georgia Institute of Technology
Polymorphism Example
• See ShapePanel
– A shape panel has a list of shapes
– ShapeCanvas has a list of shapes
– When we ask a shape to draw
• It first checks with it’s class to see if it has a draw
method and if so will execute that
• So the correct shape is drawn
– If Oval draw an oval
– If Rectangle draw a rectangle
Georgia Institute of Technology
Polymorphism Questions
• Expect questions on what is the output
when a method is called on a child object
that is declared as a parent object
– Remember that objects know what class they
are
• And all methods are resolved starting with the
object’s class then going up the inheritance tree
Georgia Institute of Technology
Static
• Static really means exists on the object that
defines the class
– A class named Class
• Objects all have a reference to their class
– getClass() will return it
• Static variables are shared by all objects of a
class
• Static methods can be called using
– ClassName.method()
• Static methods can’t access object fields
– No access to a current object (no this)
Georgia Institute of Technology
Run Time Exceptions
• NullPointerException, indicating an attempt to
reference an object using an object variable that
is null
– int[] gradeArray;
– System.out.println(gradeArray[0]);
• ArrayIndexOutOfBoundsException, indicating an
attempt to access an element that is not within
an array’s range of indexes
– gradeArray = new int[10];
– System.out.println(gradeArray[10]);
Georgia Institute of Technology
Run Time Exceptions
• ArithmeticException, such as division by
zero for integers
– System.out.println(9/0);
• ClassCastException, which occurs when
an attempt is made to cast a variable to a
class that it does not match
– List nameList = new ArrayList();
– nameList.add(new Integer(5));
– nameList.add(“Susan”);
– String name = (String) nameList.get(0);
Georgia Institute of Technology
Throwing Exceptions - AB
• IllegalArgumentException, indicating an
argument to a method that is not legal for
that method
public void setUser(String user) {
if (user.trim().equals(""))
{ throw new
IllegalArgumentException("missing user name");
}
else { this.user = user; } }
Georgia Institute of Technology
Resources
• Books
– Be Prepared for the AP Computer Science
Exam in Java Maria Litvin $13.56
– 125 Multiple-Choice Questions in Java
Maria Litvin, Gary Litvin $9.95
• On-line practice tests
– http://eimacs.com/LM/LMPlain.asp?F=beprep
ared&S=5
• Free 30 day trial
Georgia Institute of Technology
Summary
• The A Exam covers
– Basics: variables, loops, conditionals
– Debugging: Runtime exceptions, types of
errors, techniques
– OO concepts: classes, objects, encapsulation,
information hiding, interfaces, inheritance
– CS concepts: sorting, searching, algorithms,
numbers in different bases, one-dimensional
arrays, pre- and post- conditions, assertions
Georgia Institute of Technology
Summary
• The AB exam covers
– Data Structures
• Two-dimensional arrays, linked lists, stacks,
queues, trees, heaps, priority queues, sets, maps
– Algorithms
• Big-Oh notation, worst-case and average-case
time and space analysis
• Searching using hashing
• Sorting using quicksort and heapsort.
• Invariants
Georgia Institute of Technology
Download