Which of the following code segments compiles without error? That is acceptable. What is the largest temperature range for which the correct suggestion is printed (as defined above)? What value is returned by the call mystery(5) ? If the weight exceeds the weight limit, TrainCars are removed from the end of the train until the weight is in the acceptable range. << Assume String[] ray has been properly instantiated and populated with String objects. Active Page: AP Computer Science Principles Past Exam Questions < Back. We will solve questions 22 and 23 together by diagramming the objects and reference variables. Remember that substring starts at the first parameter and ends before the second parameter, and remember that we start counting the first letter at 0. Which line of code should replace /* missing code */ so that the method call selectionSort(ray) results in an array whose elements are sorted from least to greatest? Which of the following constructors compiles without error? A is 10, in the 1’s place, so our first answer is 234. After the array is instantiated, it looks like this: The for loop will execute three times: x = 0, x = 1, and x = 2. Refined Problem: Calculate the initial weight of the train. (a) TrainCar objects that are designed to transport people are called passenger cars and are represented by objects of the PassengerCar class. That’s D in hex. Our third number is 78. Consider the following code segment. Be sure you understand the difference between row-major and column-major order. Until then, it uses an ArrayList of OnlinePurchaseItem objects to track a customer’s purchases. (c) General Problem: Write the getCenter method for the RegularHexagon class. Option B is incorrect because Person does not have a no-argument constructor. Consider the following sorting method. It must check the age of the Person object passed as a parameter. B. beginning of content: Sample Responses and Scoring Guidelines. r goes from 0 to 4, so all rows are affected. Introduction. 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. (b) General Problem: Write the entire Family class. Remember that !< >= and !<= > (the same with > and >=). Add your generatePixelArray and flipImage methods to the bottom of the PixelDriver class. public boolean similar(double val, double power, double target, double tolerance). At that point we will exit the loop and no more elements will be processed. Also, unlike an array, the size of the ArrayList will change as you delete items. First, we execute what is in the parentheses. If one is found, immediately return true. Use the corresponding values in the red, green, and blue arrays as parameters to the Pixel constructor. Remember that remove also returns the removed element. Start studying AP Computer Science Principles Exam. 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. Option IV is correct. The third condition says b < a. Be sure to use the method written in part (b). We need one data element that will pass through each path. myString = "AAAAAAHAAAAAA", Putting it another way, when index = 1, we add one "A"; when index = 2, we add two "A"s; when index = 3, we add three "A"s. That’s six "A"s all together added to the beginning and end of "H" "AAAAAAHAAAAAA", The general form for generating a random number between, high – low + 1 = 50, low = 10, so high = 59. “if (element 5 of list > the last element in newList) add it to newList" 5 > 4, add 5 to newList which becomes: i = 6. Consider the following code segment. Option B does not test the first path, because it doesn’t have a number that is < −5. Write the removeExcessTrainCars method of the Train class that removes TrainCar objects one at a time from the end of the train until the train is less than or equal to the maximum weight allowed as given by the getMaximumWeight method of the Engine object. 32 . Learn vocabulary, terms, and more with flashcards, games, and other study tools. At 450,000 pounds, the train is now in the acceptable weight range. If both conditions are true, return true. The formula for computing distance is: Suppose two consecutive coordinate points of the regular hexagon are (1, 3) and (2, 4). Which code segment below can replace /* missing code */ to make the method work as intended? Create a 2-D array of type Pixel to hold the new Pixel objects. Let’s trace the loop and see what happens. (C) [Australia, Cambodia, Russia, France], (E) Nothing is printed. After careful discussion and planning, an iterative development process leads your program to completion, ensuring it meets the needs of those who end up using it. Putting the three hex values together in order, we get #7DC84E. Consider the following code segment that appears in another class. Use the midpoint formula given in the problem to compute the point at the center of the hexagon. 24 . 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. This solution uses a for loop instead of a for-each loop. Distribute the first !. increment i to 3, 3 is not < 3 so we exit the loop. Keep in mind that when you remove an item, the items with higher indices don’t stay put. Questions 31–32 refer to the following information. The E is in the 16’s place. REFERENCE MATERIALS . 26 . It takes two parameters and correctly passes them to the Depot constructor via the call to super. Each time through it puts an "A" in front of and after myString. Play. Since these are all &&s, all four conditions must be true. The overloaded constructor that is being called is the two-parameter constructor, and that constructor is going to assign its first parameter to state and its second parameter to city. Through more than 30 courses, each culminating in a rigorous exam, AP provides willing and academically For example, the ordered triple (10, 16, 20) becomes #0A1014 in hexadecimal form since 10 0A, 16 10, and 20 14, and the hexadecimal #110F03 becomes the ordered triple (17, 15, 3). Let’s use DeMorgan’s theorem to simplify the expression. When the clause associated with a true condition is executed, the rest of the statements should be skipped. Remember that the last element in an ArrayList is list.size() – 1 (just like a String or an array). In this course, students will learn to design and evaluate solutions and to apply computer science to solve problems through the development of algorithms and programs. I. AP Computer Science Principles Units 1, 2 & 3 DRAFT. 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. Nested in that for loop, write a for loop that goes through all the columns of the new array. (b) General Problem: Write the getArea method for the RegularHexagon class. This is a brand new book for an exam that is growing in popularity. Now we just have to look for the three cells specified in the problem. Refined Problem: Create a new array to hold the altered image. What is returned by the method call puzzle(3, 4) ? If the train is overweight, train operators must remove train cars from the end of the train until the train is within the acceptable weight range. That’s C in hex. General Penalties (assessed only once per problem): -1 using a local variable without first declaring it, -1 returning a value from a void method or constructor, -1 accessing an array or ArrayList incorrectly, -1 overwriting information passed as a parameter, -1 including unnecessary code that causes a side effect such as a compile error or console output. Learn vocabulary, terms, and more with flashcards, games, and other study tools. First, the order of the variables changes for no reason, and second, the names of the parameter are no help. Those two conditions can be combined into temperatures <=60. c starts at r+1 and goes to 4, so not all columns are affected. In the example, the train initially weighs 650,000 pounds. The colors of the pixels on a TV or computer screen are made by combining different quantities of red, green, and blue light. There is, however, one complete practice test with scoring guide provided on the College Board AP Computer Science A teacher website. Copy PixelDriver and the complete Pixel class into your IDE. 3 . (A) public class A extends Supernatural implements FictionalCharacter, (B) public class B extends BabyWolf, WereWolf implements FictionalCharacter, (C) public class C implements Supernatural, Werewolf, (D) public class E extends FictionalCharacter, (E) public class D extends Werewolf implements Supernatural, FictionalCharacter. Review the fundamentals of digital data representation, computer components, internet protocols, programming skills, algorithms, and data analysis. The engine is rated to pull up to a maximum weight, based on its power. Write an if statement with two conditions: this object’s name is the same as parameter object’s name and this object’s age is the same as parameter object’s age. Directions: Write all of your code in Java. We want to put a 12 in the 16’s place. We need to be sure that we have at least one piece of data for all four of those cases. The parameter is of type Adult. Shmoop is a labor of love from folks who love to teach. 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. Compute the distance between the two points, using the Math class methods pow and sqrt. Values that fail all the if conditions and execute the else clause—that is, values that are less than or equal to 45. 9 >= 7, so we remove the element at location 0. Since we passed city, state, in that order, the city name and the state name have been assigned incorrectly and will therefore be printed incorrectly. i = i + 2 = 7, 7 is not < 6 so we exit the loop. Declare 300 as a constant so there are no magic numbers in the code (not required, but good programming style). Directions: In the lesson, you will be exploring the use of variables and expressions. Show all your work. Which of the following calls returns the value 20? 33 . Option I is incorrect. This item: AP Computer Science Principles: With 4 Practice Tests (Barron's Test Prep) by Seth Reichelson Paperback $14.08 In Stock. An artist wants to manipulate the pixels on a large computer display. 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. For more information on exam weighting, download the AP Computer Science Principles Course and Exam Description. The caller’s num1 will not be changed by the method. Implement the isInNeighborhood method of the Neighborhood class. When r = 0, c will = 1,2,3,4; when r = 1, c will = 2,3,4; when r = 2, c will = 3,4; when r = 3, c will = 4. 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. 18 . Create an ArrayList of TrainCars to hold the removed cars. The first statement in the constructor needs to be super(baseWeight). The constructor takes as parameters the base weight of the car and the maximum number of passengers the car can hold. Since a WhistleStop object. AP Computer Science Principles Practice Exam #1. What are the values in array nums after the code segment is executed? 8. A. Put a 4 in the 16’s place. ... APR 7th: Review - AP Classroom Practice Exam 1. The AP Computer Science Principles Exam assesses student understanding of the computational thinking practices and learning objectives outlined in the course framework. Which of these code segments results in identical arrays? Following the same procedure, 16 * 12 = 192. The three hour long exam is structured with similar question types and scoring guidelines as previous years, and is also aimed at evaluating the real-life problem solving skills and time management abilities of each examinee. The companyCar variable still points to the object with instance variables make = "Ford" and model = "Fusion". For a complete listing of all the AP exam times (revised due to Coronavirus), check out our post 2020 AP Exam Schedule: Everything You Need to Know. Here, the parameter is of type Person. Be careful to place parentheses accurately. Points are not deducted for incorrect answers or unanswered questions. The ArrayList is correctly instantiated as an ArrayList of WhistleStop objects. (a) General Problem: Write a matches method for the Person class. %PDF-1.5 This ArrayList of removed TrainCar objects is returned by the method. Methods or constructors with the same name (and return type, in the case of methods) may have different parameter lists. No problem there. adam.cooper_96797. The else clause is skipped and "go horseback riding" is returned (incorrectly). This quiz is incomplete! For the MCQ section, you will be given: 120 Minutes Note that this is a confusing way to write overloaded constructors! Get the side length by using the method written in part (a). Let’s picture our ArrayList as a table. There are many ways to write these methods. The company bills at the end of the quarter. The parts in. Sometimes a happy medium is a better solution than either of these examples. The classes below represent families, the people in them and the neighborhoods they live in. Given a RegularHexagon object with its first vertex at (2, 5) and its fourth vertex at (4, 3), the center of the hexagon is: 2 . We’ve 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, to support students and teachers impacted by delayed school start dates. The second loop calculations can be written without a temp holding variable. It flips a pair lines on each iteration. which takes two characters starting at index 1 from s and concatenates the first four characters of crazyString. Consider the following code segment. If the flip is horizontal, write a nested for loop that goes through the array in row-major order. There are several things we can look for to identify whether a sort is Insertion Sort or Selection Sort. Return the ArrayList of removed cars (which may be empty). 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. What is printed as a result of executing the statement? Write the flipImage method, which takes as parameters a 2-D array of Pixel objects and a boolean direction to flip, where true means horizontally and false means vertically. Let’s look at the state of the array in table form. 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) Write the Person method matches . Instantiate the two ArrayLists of Person objects, one called adults and one called children. Determine whether to flip the image horizontally or vertically. 28 . What is the value of num after executing the following code statement? ASCII characters can also be represented by binary numbers. Postcondition: The returned array is the same size as the three color arrays. Its area is: You may assume that the getSideLength method works as intended, regardless of what you wrote in part (a). (a) Write the getSideLength method for the RegularHexagon class. Using integer division: 17 / 3 = 5 remainder 2. Using get(i) to get the element is unnecessary and there is no variable i. Adult extends Person, not the other way around, so a Person is not an Adult. For each iteration of the loop, an entire row is moved into its new "flipped" place in the altered array. AP Computer Science A: Practice Exam 1. 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. This is the Administration 1 date for the AP Computer Science Principles Exam. The Exam Format Section 1: The Multiple Choice Questions (MCQs) ️. Your total score on the exam is based only on the number of questions answered correctly. Option III is incorrect. These two representations have a simple relationship. doStuff is going to loop through the array, checking to see if each item is the same as the item before it. Exam Summary. Time: 90 minutesNumber of questions: 40Percent of total score: 50. Each of these types has a different way of calculating the weight of its contents. Let’s trace the calls. We have to use the method compareTo. Get the y coordinate of element 1 in the ArrayList points. 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? Check each parenthesis placement carefully. Traverse both ArrayLists looking for a Person object that equals the Person object passed as a parameter. Some easy things to look for: In the inner loop, Insertion Sort shifts items over one slot. Consider the following method. (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. Assume int[] arr has been correctly instantiated and is of sufficient size. (c) Write the getCenter method for the RegularHexagon class. The AP CSP exam covers the following topics: Big idea. The question is, which of the options correctly provides a parameter of type Adult? nations.get(1).length() gives us the length of "Australia" = 9. For each iteration of the loop, an entire column is moved into its new "flipped" place in the altered array. Notes: You may assume all imports have been made for you. When we start the for-each loop, the variable crazyString = "crazy" and the ArrayList crazyList has two elements ["weird," "enigma"]. 15 . Get the y coordinate of element 0 in the ArrayList points. I can tell this is the case because the outer loop, the one that is changing more slowly, is controlling the column variable. Approximate % of exam questions. (a) General Problem: Write the generatePixelArray method to convert three 2-D int arrays into a 2-D array of Pixel objects. companyCar is instantiated as a reference variable pointing to an Automobile object with instance variables make = "Toyota" and model = "Corolla". We can see items being shifted over and we can’t see a swap, so this is Insertion Sort. . The method is intended to return true if the value val raised to the power power is within the tolerance tolerance of the target value target , and false otherwise. Let’s take a look at what it will do. Program documentation is only needed for programs in development; it is not needed after a program is completed. It implements a no-argument constructor in the WhistleStop class, which passes the needed parameters to the Depot constructor. Under what conditions does bool evaluate to true? Question 23: c1.getX(), c2.getX(), and c3.getX() all return 30. Digital certificates are used to verify the ownership of encrypted keys used in secured communication. IndexOutOfBoundsException. Consider the following interface used by a company to represent the items it has available for online purchase. 200 – 192 = 8, so our number is C8. 176 + 5 = 181. 4 . For example, the uppercase letter “G” is represented by the decimal (base 10) value 71. Which of the following code segments properly calculates the correct total price at the end of the quarter? For example, if the parameter temp = 80, the first if is evaluated and found to be true and activity = "go swimming"; however, since there is no else, the second if is also evaluated and found to be true, so activity = "go hiking". Here, the parameter is of type Child. 331 times. Do not rewrite the code here. In order for this code to function as intended, all ifs except the first one should be preceded with. We would expect option E to be correct by reading the code, but the constructor was called incorrectly. You may assume that all parameters within method calls are not null. Create a new CoordinatePoint object with the calculated x and y points. Finish Editing. When an object is passed to a method, its reference is copied into the formal parameter. The while loop condition is (myArray[index] < 7). The caller’s num2 is not changed when the num2++ is executed inside the method. The weight of a TrainCar is its base weight plus the weight of its contents. 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. %���� The center of a regular hexagon is located at the midpoint of any diagonal of a regular hexagon. 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. They all shift over one, changing their indices. That’s E in hex. (By this point, you may recognize what the code is doing and you may be able to complete newList without tracing the remaining iterations of the loop.). Consider the following code segment. Creative Commons Attribution-Sharealike 3.0 Unported CC BY-SA 3.0. increment i to 1, 1 < 3 so we enter the loop again. A programmer intends to apply the standard Binary Search algorithm on the following array of integers. Consider the following code segment. This solution only loops halfway through the array. 19 . The calculation assumes that the passenger car is filled to capacity and that each person, including luggage, weighs 300 pounds. Before you write a single line of code in AP® Computer Science Principles, begin your program with a collaborative design process. Let’s look at what the inner loop does in general terms. Changing the formal parameter inside the method has no effect on the value of the variable passed in. (c) General Problem: Write the isInNeighborhood method of the Neighborhood class. Which of the declarations does not cause an error? What are the possible values of var after executing the statement? � Create an instance variable to hold maxPassengers. The student’s knowledge is assessed through a 3 different types of assessments, including 2 performance tasks (projects) and an end of year exam. All train cars that are removed are returned in an ArrayList in the order they are removed from the train. Option C does not test the third path, because it doesn’t have a number that is > 10. AP Computer Science Principles Unit 4: Lesson 1 Variables Explore - Sample Apps Purpose: The purpose of the assignment is to explore how information is stored and processed by programs through the use of variables and expressions. Convert the RGB ordered triple (125, 200, 78) to hexadecimal form. A train is composed of the cars listed below. 2 . Instruction Explanation List Operations (continued) Text: INSERT (list, i, value) Block: Any values in list at indices greater than or equal to i are shifted to the right. The Train class contains a removeExcessTrainCars method that ensures the engine is able to pull the train (to be completed in part (b)). AP CS P MC Practice #10. You have to know the total weight before you can start removing cars. That will assign 9 to the upper right corner of the grid like this. 78 – 64 = 14. Which of the following calls returns the value 30? The original companyCar object is now inaccessible (unless yet another variable we don’t know about points to it). Each of the three colors is represented by a value between 0 and 255, where 0 means none of that color light and 255 means as much of that color as there can be. << (b) General Problem: Write the removeExcessTrainCars method of the Train class that removes cars from the train until the train is light enough to be pulled by the engine. theadd method that takes one parameter of type Person and adds it to the appropriate ArrayList , and. How many times does 16 go into 125? Do not overwrite the array that is passed in. Write a nested for loop that goes through the array in column-major order. All temperatures that are true for multiple if statements will cause activity to be set incorrectly. This does not change the companyCar variable. You could also have stored the answer in a variable and returned that variable. The following ArrayList is returned by the method: Complete the removeExcessTrainCars method. guess(2,1) Base case! Option C is the only correctly written constructor.
Popeyes Premium Lemonade, Snap Fitness Swot Analysis, Black Belgian Malinois For Sale, Quotes From Frankenstein, Malakoff Diggins State Historic Park Weather, Cash App Flips 2020,
Popeyes Premium Lemonade, Snap Fitness Swot Analysis, Black Belgian Malinois For Sale, Quotes From Frankenstein, Malakoff Diggins State Historic Park Weather, Cash App Flips 2020,