Looking for a Tutor Near You?

Post Learning Requirement » x
Ask a Question
x

Choose Country Code

x

Direction

x

Ask a Question

x

Hire a Tutor

AP CS Exam A Tips

Published in: Programming Technology
45 Views

AP CS exam A important tips & tricks

Ahmed E / Kedah

4 years of teaching experience

Qualification: B. Sc in electrical & Computer Engineering

Teaches: SAT, Science, Android Training, Artificial Intelligence, Python Programming, Web Development, ICT Training, Computing

Contact this Tutor
  1. AP CS A Exam Exam Overview
  2. Section I: Multiple Choice 40 Questions | 1 Hour 30 Minutes | 50% of Exam Score • The multiple-choice section includes mostly individual questions, occasionally with 1—2 sets of questions (2 questions per set). • Computational Thinking Practices 1, 2, 4, and 5 are all assessed in the multiple-choice section. No penalty for guessing!
  3. Section Il: Free Response 4 Questions | 1 Hour 30 Minutes | 50% of Exam Score All free-response questions assess Computational Thinking Practice 3: Code Implementation, with the following focus • Question I: Methods and Control Structures—Students will be asked to write program code to create objects of a class and call methods, and satisfy method specifications using expressions, conditional statements, and iterative statements. Question 2: Classes—Students will be asked to write program code to define a new type by creating a class and satisfy method specifications using expressions, conditional statements, and iterative statements.
  4. Question 3: Array/ArrayList—Students will be asked to write program code to satisfy method specifications using expressions, conditional statements, and iterative statements and create, traverse, and manipulate elements in ID array or ArrayList objects. • Question 4: 2D Array—Students will be asked to write program code to satisfy method specifications using expressions, conditional statements, and iterative statements and create, traverse, and manipulate elements in 2D array objects. Even though not explicitly listed, Strings are very popular on the Free Response part of the AP exams. Know the string methods listed on the reference sheet really well! Java Reference Sheet or here: https://apcentral.collegeboard.org/pdf/ap-computer-science-a-java-quick-reference.pdf
  5. General Scoring MCQ Score: x/ 40 FRQ Score: y/ 40 Total Score: (x + y) / 80 AP Score: 5 4 3 62 (at least 78%) 47 (at least 59%) 37 (at least 46%)
  6. Multiple Choice Goal: Everyone should be able to get at least 20 out of 40 questions correct. During the first pass through the exam, only spend time on "easy" problems: problems are short and succinct and you know you can get right if you are careful. SKIP hard or wordy questions that ask about sorting algorithms(merge, selection, insertion) or binary search. During the second pass, spend time on the "medium" questions; questions that you are confident that you can get right but might need a bit more time. Note: For some, strategically it might make sense to entirely skip 4-8 of the hardest MC questions and instead spend more time on the other questions. Guess the answers to these skipped questions at the end.
  7. Free Response General Strategies for FRQS: l) Read the questions before you read the code! This will help you focus. 2) Unless a question specifically addresses efficiency, focus on clear, simple code rather than complicated, efficient code. 3) Comments are not necessary. Use only to organize your thoughts. 4) Pay attention to the code they give you: • Do you have more than one class? Use it! Did they give you methods? You will need them! • Are there instance variables that you should use? If so, use them. Do not re-declare. • Only use accessor and mutator methods to access private instance variables. • Do not re-write or change method headers. • Use parameters (names and types) as given
  8. Free Response General Strategies for FRQS: 5) If part (b) references a method written in part (a), you will likely need to use this method. If it is not clear to you how, stop and think before you write. 6) Pay attention to the return type. If it is not void, be sure to include a return statement! 7) If a method comment says I* Implementation not shown *I. You do not to implement the method. But you'll likely need to use the method in your code at least once.
  9. Free Response General Strategies for FRQS: 8) Write down some code for every question! Leave Nothing Blank! Get partial credit if not full credit! • does it need a loop? • an if statement? • return statement or assignment statement? Example l: public double funMethod() { double result; return result;
  10. More Examples Leave Nothing Blank! Get partial credit if not full credit! public int [ ] funMethod (int length) { int [ ] list — new int [length] • return list; public Array List<Bug> funMethod() { Array List<Bug> buggies new Array , return buggies;
  11. More Examples Leave Nothing Blank! Get partial credit if not full credit! public boolean funMethod (int something) { if (something > somethingE1se) return true, // must have a default return; // locked in an if return false; every return can't be
  12. Question l: Methods and Control Structures See previous years' similar FRQs:
  13. Methods and Control Structures Question I of the FRQ will likely ask you to write methods that utilize control structures(for vs while loops, conditionals). You are given (usually static) methods with parameters and will be asked to write a method that calls one of the given methods in its implementation. If a method comment says I* Implementation not shown *I. You do not to implement the method. But you Il likely need to use the method in your code at least once. AVOID using arrays/arraylists for this problem. 2019 #1 is a good example of this problem.
  14. Methods and Control Structures Likely you will need to use for loops and if-else if-else conditionals. Likely your method will return some value. See its return type in its header. Using Strings and its methods can be required here in this question(or Question 2). See for example 2017 #3 for a String question that fits "Methods and Control Structures" question. You should know how to use substring(int beg, int end), substring(int beg), indexOf, equals, length and compareTo methods. See the College Board reference sheet.
  15. String methods Method name String (String str) nt length ( ) substring (indexl, index2 or substring (indexl boolean equals (String other) nt compareT0 (String other) IndexOf (Str) Description Constructs a new String object that represents the same sequence of characters as str Returns number of characters in this string Returns the characters in this string from indexl (inclusive) to index2 (exclusiy.e); if index2is omitted, grabs till end of string Returns true if this is equal to other; returns false otherwise Returns a value < 0 if this is less than other; returns zero if this is equal to other; returns a value > O if this is greater than other Returns index where the start of the given string appears in this string (-1 if not found)
  16. String method examples print In (sl . length ( ) ) ; / / index String System . out . // 19 System . out System . out System. out System . out System . out System . out . String 0123456789012345678 programming in java " . print In (sl . indexOf ("i")); // 8 . print In (sl . indexOf ("gram") ) ; . print In (sl . indexOf ("hi")) ; . print In (sl . substring (7, 10)); // "min" // "in java" . print In (sl . substring (12)) ; print In (sl . substring (2 , 3) ) ; // o // "g in ja' sl . substring (10, 17) ;
  17. indexOf Example indexOf can be confusing. Here' s an example . public static mystery (String st r) { String answer for (int i — O; i < st r. length(); String current Letter — st r. if ("aeiou" . indexOf (current answer += current; return answer; What is the output? System. out . print In (mystery (" Answer: a ia cat 1 n substring (i, etter) ! _ hat"))
  18. Do Problem 2018 Complete 2018#2. This is a good problem that uses ID array, Arraylist, and Strings and is a good Question I (Methods/Control Structures) type of problem. Also do the following 2018 2017 #3, 2021 to prepare for Question l.
  19. Question 2:VVriting Classes See previous years' similar FRQs: 2019 2021 2015 2021#2
  20. Question 2 This question will ask you to write an entire class including private instance variables, constructors and methods. The class implementation typically involves 2 —4 instance variables, one constructor and 2 — 3 instance methods. AVOID using arrays/arraylists for this problem. Otherwise you'll be doing needless for loops. Consider a variable(int or double) that accumulates(sums) values rather than keeping track of each value in an array/arraylist. The Point class' implementation on the next slide provides an example of the anatomy of a class.
  21. An Implementation of Point x +— dx; public class Point { private int x; private int y; int instance variables constructors to initialize instance variables. newY) { pub 1 i c y pub 1 i c pub c Point (int newX, newX ; new Y ; void translate (Int dx, mutator method int dy) { accessor method double distanceTOOrigin ( ) { return Math. sqrt (x * x + y);
  22. Typically, the question will give you examples of method calls and corresponding outputs and require you to create a class that satisfies those specifications. 2019 # 2 is a great example of this. explains you how to Statements and Expressions StepTracker tr = new StepTracker(10000) i tr . activeDays ( ) ; tr . averageSteps ( ) ; tr . addDaiIySteps (9000) ; . addDaiIySteps (5000) ; tr . activeDays ( ) ; tr . averageSteps ( ) ; Value Returned (blank if no val 0.0 0 7000.0 Comment Days with at least 10,000 steps are considered active. Assume that the parameter is positive. No data have been recorded yet. When no step data have been recorded, the average Steps method returns O . O. This is too few steps for the day to be considered active. This is too few steps for the day to be considered acti ve. No day had at least 10,000 steps. The average number of steps per day is (14000 / 2). And what methods to implement!
  23. Step Tracker Students have implemented correctly Step Tracker(2019 #2) using an ArrayList. However, avoid using ArrayList/l D Arrays or 2D arrays for #2. Otherwise, you'll be doing needless for loops in your implementation.
  24. The previous problem(2019 #2) is simple problem that involves only working with one class. Another problem that is slightly more complex is 2021 #2. This problem involves writing a class that uses ANOTHER given class. In this problem, you are given a SingleTable class with accessors and mutators methods and you are asked to write the CombinedTable class that uses the SingleTable class. Try this problem. Here's a hint:A subtle error to this problem is not using SingleTable instance variables! If you use int and double instance variables, your answer will not receive full credit because of: 67 5 t2 . setViewQuaIity(80) ; c2 .getDesirabi1ity() ; Changing the view quality of one of the tables that makes up c2 changes the desirability of c2, as illustrated in the next line of the chart. Since setViewQua1ity is a SingleTab1e method, you do not need to write it. Because the view quality of t2 changed, the desirability of c2 has also changed.
  25. Question 2 Thus, the take away is that if the problem gives you a class(SingleTable) and requires you to use it another class(CombinedTable), it is likely that you will need to make at least one instance variable(for example, SingleTable tl) in the class that you are writing(CombinedTable). Please do the following 2019 #2, 2021 #2, 2020 #2, 2016 , 2015 #2 and check your solutions to prepare for Question 2.
  26. Question 3:Arraylist/ I D Array See previous years' similar FRQs: 2010 2013
  27. ArrayList/ I D Arrays We will first prepare for the FRQs by reviewing ArrayList and I D arrays. This will be Question 3 on the Free Response. From previous years' exams, it is likely that Question 3 is an ArrayList question instead of/in addition to an ID array question.(ArrayList or both, unlikely to be just a ID array question) See the following problems 2010 2013 2017 2018 It's very common to have a class(e.g Student) and another class which contains either a ID array of Student objects or an ArrayList of Student objects. publxc class Student { public String getName ( ) { public double getGpa ( ) { ... }
  28. ArrayList/ I D Arrays public class Course { private students ; public Course ( ) new • students OR public class Course { private Student [ students ;
  29. Traversing I D Array vs.ArrayList Arrays: double sum for (int i sum +— ArrayLists: double sum for (int i sum +— o; O; i < students. length; students [i] .getGpa ( ) ; o; O; i < students. size(), students . get (i) .getGpa ( ) ;
  30. Traversing I D Array vs.ArrayList Use for each loops if you are only traversing the arraylist and not removing items from it. Both Arrays and Arraylists: double sum for (Student s: students) { sum +— s.getGpa ( ) ; // notice no [i] and no get (i) !!
  31. ArrayList Remember for Arraylists that if you remove an item, items to the right of it will shift left! And if you add an item to the list, items will shift right to accommodate! Make sure to take this into account when you are adding or removing items.
  32. ArrayList/ I D Array Tips When using the ArrayList method remove(), remember you can only REMOVE BY INDEX (not by object), so you must use a traditional for loop (and NOT a for each loop). for(int i=0; i<list.size(); if(list.get(i).getScore() 50) list.remove(i); i--;//AND don't forget to decrement the index! [IOR traverse the list backwards, i.e. for(int I , i>=O, i--){ if(list.get(i).getScore() 50) list.remove(i--);
  33. ArrayList/ I D Array Tips Avoid array and ArrayList out-of-bounds exceptions! Especially when comparing consecutive elements. Example: You need to compare consecutive elements to determine if the values are increasing. public boolean increasing (int [ ] numbers) { for (int i O; i < numbers. length—I; if (numbers [i] >— numbers [i +1] ) return false; return true;
  34. Finding the smallest or largest When you need to return an element in a list (i.e. largest, smallest,.. .), assign the initial element to the first one in the list. Example : You need to find the Dog with the most fleas. // returns the Dog object in pack with the most fleas public Dog mostF1eas (ArrayList<Dog> pack) { pack. get (O) ; Dog most for (Dog dog : pack) if (dog . getNumEIeas ( ) > most. getNumF1eas ( ) ) — dog; most return most;
  35. Manipulating an Array using Arraylist An ArrayList can be helpful when you are trying to manipulate an array (i.e. remove items, rearrange in random order, etc.). Example: If you need to remove several objects from an array based one some condition, a strategy would be to save all the objects to an ArrayList and remove the objects before storing the remaining objects back to the array. See code on the next slide.
  36. Manipulating an Array using Arraylist / / returns a new array with bad things removed public Thing [ ] removeBadThing (Thing [ ] widgets) { ArrayList<Thing> good — new ArrayList<Thing> ( ) ; for (Thing wid : widgets) { // i.e good good. add (wid) ; Thing [ ] goodOnes new Thing [good. size ( ) ] , for (int i —O; i < goodOnes . length; i++) goodOnes C i] good. get (i) ; return goodOnes;
  37. Question 3 Please do the following 2010 , 2013 2017 2018 #2, 2021 #3 and check your solutions to prepare for Question 3.
  38. Question 4: 2D Array See previous years' similar FRQs: 2019 2017 2016 2021#4
  39. Row Major Order Traversal Example : Count the number of Students objects whose GPA is above a threshold. (row major order) public class Course Student C] C] students; // constructors not shown public int aboveThresh01d (double threshold) { int count for (int row = O; row < students . length; row+ ) { for (int col — O; col < students [O] . length; col++) { if (students [row] [col] . getGpa ( ) > threshold) count++; return count;
  40. Column Major Order Traversal Example : Count the number of Students objects whose GPA is above a threshold. (column major order) public class Course Student C] C] students; // constructors not shown public int aboveThresh01d (double threshold) { int count for (int co 1 — O; col < students [O] . length; col++) { for (int row — O; row < students. length; row + ) { if (students [row] [col] . getGpa ( ) > threshold) count++; return count;
  41. Along One Row Example : Count the number of Students objects whose GPA is above a threshold in the given row. public class Course Student C] C] students; // constructors not shown public int aboveThresh01d (int row, double threshold) { int count for (int co 1 — O; col < students Crow] . length; col++) { if (students [row] [col] . getGpa ( ) > threshold) count++; return count;
  42. Along One Column Example : Count the number of Students objects whose GPA is above a threshold in the given column. public class Course Student C] C] students; // constructors not shown public int aboveThresh01d (int col, double threshold) { int count for (int row = O; row < students . length; row+ ) { if (students [row] [col] . getGpa ( ) > threshold) count++ ; return count;
  43. Major Diagonal Traversal Example : Count the number of Students objects whose GPA is above threshold along the major diagonal. Assume 2D array is square. public class Course Student C] C] students; // constructors not shown public int aboveThresh01d (double threshold) { int count for (int i — O; i < students. length; i + ) { if (students i [i] .getGpa() > thresho d) count++ ; return count;
  44. Minor Diagonal Traversal Example : Count the number of Students objects whose GPA is above threshold along the minor diagonal. Assume 2D array is square. pub ic class Course Student C] C] students; // constructors not shown public int aboveThresh01d (double threshold) { int count int dim — students. for (int i if (students [i count++; return count; ength; dim; 1++) { [dim 1 — i] .getGpa ( ) > threshold)
  45. Question 4 Please do the following 2019 #4, 2018 #4, 2017 #4, 2016 #3, 2021 and check your solutions to prepare for Question 4.