ap computer science principles practice exam 1

Consider the following class declarations. What are the values in array nums after the code segment is executed? That’s C in hex. This way of representing colors is referred to as RGB, for red-green-blue, and the color values are written in ordered triples like this (80, 144, 240). Get the y coordinate of element 3 in the ArrayList points. Just like in question 12, the order of the city and province has been switched. Method findSomeone is expecting a parameter of type Adult. Precondition: The three color arrays are all the same size and contain int values in the range 0–255. Create a 2-D array of type Pixel to hold the new Pixel objects. ���gvy5��N�]��`3� theisInFamily method that takes a Person object as a parameter and returns a boolean indicating whether that Person is a member of the object’s family. Use any two consecutive entries in ArrayList points. Edit. Option I correctly accesses and processes every element in the ArrayList. It’s hard to imagine why you would want to default to constructing a station in the tiny town of Waubaushene, but if you want to do that, this code will do it for you. Let’s use DeMorgan’s theorem to simplify the expression. When a primitive argument (or actual parameter) is passed to a method, its value is copied into the formal parameter. We need to put 13 in the 1’s place. Trains need to be checked to make sure that their weight can be pulled by their Engine . You may implement as many interfaces as you like, but you can extend only one class. Now our ArrayList looks like this: increment i to 1. nations.size() = 5, 1 < 5, so we enter the loop. Start studying AP Computer Science Principles Semester 1 Exam Vocab. /Filter /FlateDecode Option II uses a for-each loop. Be sure to use the matches method of the Person class written in part (a) to compare the Person objects. Let’s walk through it. arr[1 / 2] = arr[0] = 1 (don’t forget integer division). That’s 100. You may assume all imports have been made for you. If Child extended Adult, this would be the correct constructor, but Child extends Person. Consider the following code segment. return 3/2 = 1 (integer division). Those two conditions can be combined into temperatures <=60. Write a for loop that goes through all the rows of the new array. 331 times. (D)   if (arr[j].compareTo(arr[small]) > 0), (E)   if (arr[j].compareTo(arr[small]) < 0), Time: 90 minutesNumber of questions: 4Percent of total score: 50. 78 – 64 = 14. Declare 300 as a constant so there are no magic numbers in the code (not required, but good programming style). Option A does not test the fourth path, because 12 and 15 are both > 10. 19 . First iteration: k = 1, enter the loop with index = 0; value = 1; counter = 1; Second iteration: k = 2, enter the loop with index = 1; value = 1; counter = 2; Item 2 != item 1, execute the else clause. © 2016-2021 All site design rights belong to S.Y.A. 33 . If you are the copyright holder of any material contained on our site and intend to remove it, please contact our site administrator for approval. See the scoring guidelines included with the explanations for each of the questions and award yourself points based on those guidelines. Option A is incorrect. What is the largest temperature range for which the correct suggestion is printed (as defined above)? Since the code is written as a cascading if-else, no more conditions are evaluated and flow of control jumps to the return statement. The parameters may differ in type or number. myString = "AHA", The third iteration of the outer loop, index = 2, the inner loop executes two times adding two "A"s in front of and after myString. The call to super() will cause a compile time error. Create an ArrayList of TrainCars to hold the removed cars. This solution uses methods instead of directly accessing the instance data. Questions 11–14 refer to the following class definition. AP Computer Science Principles Units 1, 2 & 3 DRAFT. Which of the following code segments properly calculates the correct total price at the end of the quarter? We can see items being shifted over and we can’t see a swap, so this is Insertion Sort. After the array is instantiated, it is filled with 0s because that is the default value for an int, so anything we don’t overwrite will be a 0. AP CS P MC Practice #8 ... implementing it into the event handlers so the code is reduced and not being repeated on certain Create Sample F 4 of 5 AP Computer Science Principles Effective Fall 2017 Page 5 of 5 event handlers. (b)  General Problem: Write a flipImage method that takes a 2-D array of Pixel objects and flips it into a mirror image, either vertically or horizontally. This nested for loop is traversing the array in column major order. Let’s look at the state of the array in table form. They are now aliases of each other. public boolean similar(double val, double power, double target, double tolerance). To … (C)   [Australia, Cambodia, Russia, France], (E)   Nothing is printed. What are the possible values of var after executing the statement? 24 . Get the x coordinate of element 3 in the ArrayList points. Directions: Choose the best answer for each problem. The super call causes a compile time error. stream 3 . Review the fundamentals of digital data representation, computer components, internet protocols, programming skills, algorithms, and data analysis. We need to find out if the current element being examined is smaller than the element at index small, or, in other words, if arr[j] is less than arr[small]. You may assume that all preconditions are met when making calls to methods. small is storing the index of the smallest element we have found so far. guess(2,1) Base case! You may assume that all parameters within method calls are not null. When the loops are complete, return the new array. Students taking the AP Computer Science Principles Exam are responsible for demonstrating knowledge of the above mentioned skills and abilities. This is called. Shmoop is a labor of love from folks who love to teach. /Length 625 It takes two parameters and correctly passes them to the Depot constructor via the call to super. Let’s trace the calls. Refined Problem: Create a new array to hold the altered image. Big idea 2: Data. You may assume all import statements have been included where they are needed. Directions: Write all of your code in Java. (b)  The Family class models a family that consists of one or more adults and zero or more children. 16 * 7 = 112. That is acceptable. You can read the for-each like this: “For each String (which I am going to call s) in crazyList. Determine whether to flip the image horizontally or vertically. AP Computer Science Principles End-of-Course Exam . We can eliminate options B and D immediately by noticing that active is a boolean and will therefore print as either "true" or "false" and not as "active" even though that is more informative. AP Computer Science Principles Create Performance Task Due Date Thu, May 20, 2021, 11:59 PM EDT AP Computer Science Principles End-of-Course Exam Copy RegularHexagonDriver into your IDE along with the complete RegularHexagon and CoordinatePoint classes (including your solutions). Maybe yours is a bit different from our sample solutions and you are not sure if it works. Show all your work. Child is not a superclass of Adult. The length of list is increased by 1, and value is placed at index i in list. Some problems take longer than others. Start studying AP Computer Science Principles Exam. When the clause associated with a true condition is executed, the rest of the statements should be skipped. The student’s knowledge is assessed through a 3 different types of assessments, including 2 performance tasks (projects) and an end of year exam. "if (element 6 of list > the last element in newList) add it to newList" 1 is not > 5, so we do not add it. Our second number is 200. . You should recognize that the code in the loop is a simple swap algorithm that swaps the value at nums[x][0] with the value at nums[x][2]. Its area is: You may assume that the getSideLength method works as intended, regardless of what you wrote in part (a). So we have a 7 in the 16’s place. Copy PixelDriver and the complete Pixel class into your IDE. A diagonal of a regular hexagon is a line segment that connects two points that lie opposite each other on the hexagon. This solution only loops halfway through the array. i = 0. nations.size() = 6, 0 < 6 so we enter the loop. The following complete Engine class is used to represent the train’s engine. 9 >= 7, so we remove the element at location 0. In addition, although the outer loop is traversing the columns from least to greatest, the inner loop is working backward through the rows. Row-major order is more common, but column-major order will also work here.). ... APR 7th: Review - AP Classroom Practice Exam 1. Our first number is 125. 22 . You will also need to add this import statement as the first line in your RegularHexagon class: import java.util.ArrayList; (a)  General Problem: Complete the PassengerCar class, which extends the TrainCar abstract class. The question is, which of the options correctly provides a parameter of type Adult? Save. Using variables, like in the alternate solution, can help you be consistent. which takes two characters starting at index 1 from s and concatenates the first four characters of crazyString. REFERENCE MATERIALS . First split the hexadecimal number into its three components: EA, 27, B5. The Exam Format Section 1: The Multiple Choice Questions (MCQs) ️. 176 + 5 = 181. Various train cars are represented by the TrainCar class. You could also have stored the answer in a variable and returned that variable. First, we execute what is in the parentheses. The third condition says b < a. So index will equal 0, 1, 2, 3 in successive iterations through the loop. You may assume that the parameters in method calls are not null. Because the condition is (myArray[index] < 7), we will start at element 0 and continue until we come to an element that is greater than or equal to 7. The only statement inside the outer loop is the inner loop. To convert from decimal to hexadecimal (base 16), we need to remember the place values for base 16. Always think: do I want length or length – 1? myString = "AAAHAAA", The fourth (and last) iteration of the outer loop, index = 3, the inner loop executes three times, adding three more "A"s in front of and after myString. Let’s take a look at what it will do. num1 remains equal to 2, even though the method’s num1 variable is changed to 4. num2 is reset to 4, because the method returns that value, and values[4] is set to 3. (A)   { {0, 1, 0}, {3, 4, 3}, {6, 7, 6} }, (B)   { {0, 0, 0}, {3, 3, 3}, {6, 6, 6} }, (C)   { {2, 1, 0}, {5, 4, 3}, {8, 7, 6} }, (D)   { {0, 1, 2}, {3, 4, 5}, {6, 7, 8} }, (E)   { {8, 7, 6}, {5, 4, 3}, {2, 1, 0} }. In the second loop, d goes from 0 to 4, so all rows are affected, and c always equals r, so the diagonals are filled in with their row/column number. Which of the following shows the elements of the array in the correct order after the second pass through the outer loop of the sorting algorithm? Using integer division: 17 / 3 = 5 remainder 2. Since each type of TrainCar does this differently, the getTotalWeight method is an abstract method. The engine has a maximum weight rating of 475,000 pounds. %PDF-1.5 The company decides to offer a 20 percent off promotion on all items purchased in September. The actual and formal parameters become aliases of each other; that is, they both point to the same object. That evaluates to a boolean. About AP ® The College Board’s Advanced Placement Program ® (AP ®) enables students to pursue college-level studies while still in high school. Under what conditions does bool evaluate to true? AP Computer Science Principles - Big Idea 5 Impact of Computing Practice Test Question 1 Which of the following are true statements about digital certificates in Web browsers? AP CS P MC Practice #10. In computer graphics, RGB colors can be specified several ways. That’s a perfectly fine approach provided no subsequent code will ever set it back to false. We need one data element that will pass through each path. Learn AP Computer Science Principles using videos, articles, and AP-aligned multiple choice question practice. Consider the following method declaration in a different class. Use the midpoint formula given in the problem to compute the point at the center of the hexagon. Consider the following expression. Look at the algorithms and coded solutions, and determine if yours accomplishes the same task. Option III is also correct. Exam Overview. Directions: Write all of your code in Java. i = 3. We could assign it to a boolean variable and return the variable, but we can also just return the expression as in option E. This problem requires you to understand that primitives are passed by value and objects are passed by reference. 200 – 192 = 8, so our number is C8. The resulting color is a kind of medium blue. That’s E in hex. Compute the area using the value returned by the sideLength method, and the Math class methods pow and sqrt. AP COMPUTER SCIENCE PRACTICE TEST – 1D ARRAYS Name: _ Multiple Choice: 1. What is returned by the algorithm when a search for 50 is executed? What values are stored in myArray after executing the code segment? This solution uses a for loop instead of a for-each loop. Remember to change|| to &&. << B. We extended the deadline for final digital submission of AP Art and Design portfolios and AP Computer Science Principles (CSP), AP Seminar, and AP Research performance tasks to Thursday, May 20, 2021, 11:59 p.m. EDT. In pseudocode, the if statement says "if (element 1 of list > the last element in newList) add it to newList" Since 4 > 2, add 4 to newList, which becomes: i = 2. i = 5. Option V is incorrect. If the weight exceeds the weight limit, TrainCars are removed from the end of the train until the weight is in the acceptable range. (A)   All integers from 1 to 59 (inclusive), (B)   All integers from 10 to 59 (inclusive), (C)   All integers from 10 to 60 (inclusive), (D)   All real numbers from 50 to 60 (not including 60), (E)   All real numbers from 10 to 60 (not including 60). 125 – 112 = 13, so we have 13 left. Implement the isInNeighborhood method of the Neighborhood class. Refined Problem: Use the area formula given in the problem to compute and return the area of the hexagon. 15 . First, the order of the variables changes for no reason, and second, the names of the parameter are no help. Which of these code segments results in identical arrays? Consider the following code segment. Also, unlike an array, the size of the ArrayList will change as you delete items. Remember that the call to super must come first. Calculate the weight of the train by adding the weight of the Engine with the weights of all the TrainCar objects in trainCars. Write a constructor that takes the car’s baseWeight and its maxPassengers as parameters, calls super, passing the baseWeight, and sets the maxPassengers instance variable. The company bills at the end of the quarter. This is not necessary but it reduces the amount of typing and the chance of an off-by-one error with length, as opposed to length – 1. The dimensions of this array are the same as any of the color arrays because there is a precondition saying all the arrays must be the same size. Our Test Prep resources will help you prepare for exams with fun, engaging, and relatable materials that bring the test to life. This item: AP Computer Science Principles: With 4 Practice Tests (Barron's Test Prep) by Seth Reichelson Paperback $14.08 In Stock. (a)   Write the getSideLength method for the RegularHexagon class. So for each String s in crazyList we execute the assignment statement: The first time through the loop, s = "weird" and crazyString = "crazy" so the assignment becomes: The second time through the loop, s = "enigma" and crazyString = "eicraz" so the assignment becomes: There are four possible paths through the code. Finish Editing. Be sure to use the method written in part (b). Instantiate a new Pixel object, passing the values in the red, green, and blue arrays at the position given by the two loop counters, and assign it to the element of the Pixel array given by the two loop counters. Child extends Person, not Adult, so a Child is not an Adult. Learn vocabulary, terms, and more with flashcards, games, and other study tools. 8. The Binary Search algorithm should not be applied to this array! You may assume that declarations of variables and methods appear within the context of an enclosing class. Now we have: Now do the addition left to right. Note that this is a confusing way to write overloaded constructors! Create an if-else statement with one clause for a horizontal flip and one for a vertical flip. a year ago. A Person reference variable can be downcast to an Adult since Adult extends Person. Option II is correct. nations.get(2).length() gives us the length of "Russia" = 6. increment i to 3. nations.size() = 4, 3 < 4 so we enter the loop. A regular hexagon is a six-sided geometric figure in which all six sides are the same length and all the interior angles measure 120 degrees. Write a nested for loop to move all the Pixels to their mirror-image location in the new array, either horizontally or vertically. Access the x and y values by using the methods in the CoordinatePoint class. The three numbers range in value from 0 to 255 (inclusive). However, the Depot class does not. Return the ArrayList of removed cars (which may be empty). I can tell this is the case because the outer loop, the one that is changing more slowly, is controlling the column variable. Time: 90 minutesNumber of questions: 40Percent of total score: 50. Directions: In the lesson, you will be exploring the use of variables and expressions. After the add statements, ArrayList nations looks like this: It looks like perhaps the loop is intended to remove all elements whose length is greater than or equal to 7, but that is not what this loop does. To make the example clearer, red is set to the original row number, green is set to the original column number, and blue is constant at 100. Be aware that you should, when possible, use methods that are defined in the classes provided as opposed to duplicating them by writing your own code. The expression simplifies to answer = 2 + 5 = 7 (remember order of operations). We have to use the method compareTo. What is the value of num after executing the following code statement? This question requires that you understand the two uses of the + symbol. The parts in. Like 1a, none of the variables are required. 31 . What value is returned by the call mystery(5) ? Get the y coordinate of element 1 in the ArrayList points. Options D and E are incorrect because of the “extends” phrase. The center of a regular hexagon is located at the midpoint of any diagonal of a regular hexagon. The CoordinatePoint class represents a point on the coordinate plane.
Reaper And Reapette Spirit Location, Benjamin Stone Age, Cobia 301 Performance, Krait Phantom Vs Mk2, Songs About Idiots, John Murchison Hbo, Veiled Riven Mod Price,