Image From Wikipedia.
⛔STOP!⛔ Before you look at the answers make sure you gave this practice quiz a try so you can assess your understanding of the concepts covered in unit #. Click here for the practice questions:
AP Name Unit 5 Multiple Choice Questions.Facts about the test: The AP Computer Science A exam has 40 multiple choice questions and you will be given 90 minutes to complete the section. That means it should take you around 34 minutes to complete 15 questions.
*The following questions were not written by CollegeBoard and although they cover information outlined in the AP Computer Science A Course and Exam Description the formatting on the exam may be different.
A. private int getX()
B. public int getX()
C. private void getX()
D. public void getX(int x)
Answer: public=modifier int=return type getX = name of the method
📄
Study AP CSA, Unit 5.1: Anatomy of a Class
A. The value result.length() - 1 is printed.
B. The value 1 is always printed
C. The value 0 is always printed
D. A substring containing the last character of word2 is printed.
Answer: result will always be 0
📄
Study AP CSA, Unit 5.4: Accessor Methods
A. int rn = (int) (Math.random() * 25) + 60;
B. int rn = (int) (Math.random() * 26) + 60;
C. int rn = (int) (Math.random() * 25) + 36;
D. int rn = (int) (Math.random() * 36) + 25;
Answer: random is in the Math library.. values can be 0-1, multiplied by 36 gives values between 0 & 35.999. adding 25 gives 25-60
📄
Study AP CSA, Unit 5.6: Writing Methods
A. The value is always true
B. The value is always false
C. The value is true when a has the value false, and is false otherwise
D. The value is true when either a or b has the value true, and is false otherwise.
Answer: && is AND ! is NOT || is OR
📄
Study AP CSA, Unit 5.6: Writing Methods
A. The Boolean expression in the for loop header should be changed to i < animals.length
B. The Boolean expression in the for loop header should be changed to i < animals.length -1.
C. The Boolean expression in the for loop header should be changed to i < animals[i].length
D. The condition in the if statement should be changed to animals[i].equals(str).
Answer: exclued the case where i could be = to animals.length
📄
Study AP CSA, Unit 5.6: Writing Methods
A. II only
B. I and II only
C. II and III only
D. I, II, and III
Answer: definitely not III. II works (and is in every choice). Although I is close, it won't work
📄
Study AP CSA, Unit 5.6: Writing Methods
A. ["one", "four", "five"]
B. ["three", "four", "two"]
C. ["three", "two", "five"]
D. ["three", "four", "five"]
Answer: "one" and "two" are replaced with "three" and "four" and then "five" added after
📄
Study AP CSA, Unit 5.6: Writing Methods
A. The code segment causes an IndexOutOfBoundsException for all lists because of an incorrect Boolean expression in the for loop
B. The code segment skips some elements of myList because the indexes of all subsequent elements change by one when a list element is removed.
C. The code segment causes an IndexOutOfBoundsException for lists with at least one even element because the indexes of all subsequent elements change by one when a list element is removed.
D. The code segment removes the wrong elements of myList because the condition in the if statement to test whether an element is even is incorrect
Answer: The code skips some of the elements because some of the indexes change by one when an element is removed
📄
Study AP CSA, Unit 5.6: Writing Methods
A. 6
B. 68
C. 124
D. 1212
Answer: the code segment is not in the class Thing1 or Thing2
📄
Study AP CSA, Unit 5.6: Writing Methods
A. a method
B. a variable
C. a static parameter
D. a return value
Answer: definition of a class
📄
Study AP CSA, Unit 5.1: Anatomy of a Class
A. a way to initialize a mutator
B. a way to initialize a list
C. a way to initialize a method
D. a way to initialize a field
Answer: definition of a constructor, also used to initialize fields in a new object
📄
Study AP CSA, Unit 5.2: Constructors
A. An object is one element in a constructor method
B. An object names a variable that can change in a program
C. An object does the actual work in an object-oriented program
D. An object is a static variable in a program
Answer: definition of an object in an OOP
📄
Study AP CSA, Unit 5.2: Constructors
A. name.substring(7);
B. Math.pow (3,6);
C. circle.getDiameter();
D. student.setEmail("smith@student.dist221.org");
Answer: A static method must be called by the class & has the form: className.methodName(parameters)
A. general code for a mutator
B. general code for a getter
C. general code for an accessor
D. general code for a static method
Answer: a mutator is also known as a setter
📄 Study AP CSA, Unit 5.5: Mutator Methods
A. A mutator method is accessible outside of the class
B. A mutator method is often a static method
C. A mutator method often sets the instance variable to a value in its parameter
D. A mutator method is also a getter for the method
Answer: definition of a mutator method
📄 Study AP CSA, Unit 5.5: Mutator Methods
🦘 Jump to AP CSA Unit 6 Multiple Choice Questions
🤝 Connect with other students studying AP CSA with
Hours