AP Computer Science Exam Review Guide

Hi college confidential -

I just finished off an intro Java guide and figured this might help some people out. It has more detail than the AP expects, but there’s a lot of overlap.

http://1drv.ms/1xboS9B

Wow, thank you for the guide! It’s a lot clearer and easier to read than many sites I tend to use, and I really appreciate you sharing it! :slight_smile:

Glad to be of help. Email me if anything is confusing.

Hello,

When completing a free response part (hand-written), sometimes you realize you have left out a huge chunk of code that needs to be at the beginning of the code, and simply can’t be squeezed in. On the AP Exam, is it necessary to erase and start over, or can arrows/boxes/whatever be draw to indicate that a certain section of code written on the bottom of the page is intended to be at a location near the beginning of the code?

Thanks, I know it’s a weird and particular question.

@apotoxin Nice guide. Just curious, does your guide talk about mutable vs. immutable datatypes (can’t find it anywhere)? I feel like that would be extremely useful to anyone learning Java, regardless of whether it is covered in APCS (it should, but I’m not 100% sure since I never took APCS).

For example:

ArrayList lst = new ArrayList();
lst.add(5);

ArrayList lst2 = lst;
lst2.add(17);

System.out.println(lst); // we expect lst = [5], lst2 = [5, 17] but this is not the case.

@McTeach Speaking as a veteran AP Reader … as long as the reader can figure out how the arrows/boxes/etc. work, it’s fine. But make sure that it actually is clear where things go; if you’re drawing more than one set of arrows, then it’s probably time to erase it and start over.

@McTeach I drew arrows on my exam - didn’t seem to hurt my score.

@MITer94 I don’t know if I explicitly discussed it, because it’s more of an issue in functional programming languages, or in hybrid languages like Scala, that really make serious use of immutability. It does have some important applications in Java (for example, you should not use mutable fields when overriding the Object class’ equals method - see http://www.artima.com/lejava/articles/equality.html), but discussions of this nature are beyond the scope of the AP exam / an introduction to CS. Still, as I extend the guide I may venture into topics that are more advanced, and I’ll add discussions about them.

With particular regard to your example, this is less to do with mutability and more to do with an understanding of Java pointers. The basic structure of an object definition is:

ObjectType objectName = new ObjectType(arg1, arg2, …);

The right-hand side of the assignment is the “value,” i.e. the newly constructed object. The left-hand side of the assignment is the reference, or “pointer,” to which the object is assigned.

The statement “ObjectType objectName2 = objectName” simply creates a new pointer and assigns it to the object to which objectName points. Now there are two pointers, objectName and objectName2, that point to the same object. Thus, when you make changes to objectName, changes are reflected in objectName2. It’s not that there are 2 objects that somehow have their fates intertwined - they are actually the SAME object.

Analogy:

Say Mom gives Tim and Tom a toy to share. Tim identifies the toy as “Tim’s toy.” Tom identifies the toy as “Tom’s toy.” Now say Tom’s toy breaks. What happens to Tim’s toy? It breaks also! Why? It’s the same toy; it just had two different labels.

@apotoxin ah, I see, thanks. I’m still not really fluent with Java (currently taking a software class which is in Java) so my example wasn’t probably the best.

A better example might be String vs. StringBuilder…

Thanks, this is amazing! How can I add this OneNote file to my own Microsoft OneNote notebooks so I can have it everywhere I go?

To be honest I’m not sure. There might be an FAQs section of OneDrive that can answer that?

Oh wow~ This offers so much insight I never realized about the leels of programming, abstraaction n all that good stuff! sweet guide~

Do you have an updated link for your guide? Thank You

Updated link: https://onedrive.live.com/redir?resid=CB5BE2275DD8DE1!119&authkey=!AE4OETU-hOiHh0c&ithint=onenote%2c

Microsoft decided to kill the short URL feature, and it broke all the old links.