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)
πΒ Study AP CSA, Unit 5.7:Β Static Variables and Methods
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