
AP CSA 5.6/5.7 (Methods & Static)
Authored by Herman Galioulline
Computers
10th Grade
Used 21+ times

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
5 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
2 mins • 1 pt
Consider the following class declaration. The changeWeather method is intended to update the value of the instance variable weather and return the previous value of weather before it was updated.
Which of the following options should replace /* missing code */ so that the changeWeather method will work as intended?
String prev = w;
return weather;
String prev = weather;
return w;
String prev = w;
return prev;
weather = w;
String prev = weather;
return prev;
String prev = weather;
weather = w;
return prev;
2.
MULTIPLE CHOICE QUESTION
2 mins • 1 pt
The isGreater method is intended to return true if the value of one for this BoolTest object is greater than the value of one for the BoolTest parameter other, and false otherwise. The following code segments have been proposed to replace /* missing code */.
I. return one > other.one;
II. return one > other.getOne();
III. return getOne() > other.one;
Which of the following replacements for /* missing code */ can be used so that isGreater will work as intended?
I only
II only
III only
I and II only
I, II, and III
3.
MULTIPLE CHOICE QUESTION
2 mins • 1 pt
The code segment does not compile because the setStatus method should be called on an object of the class Gadget, not on the class itself.
The code segment does not compile because the static variable status is not properly initialized.
The code segment creates two Gadget objects a and b. The class Gadget’s static variable status is set to 10, then to 3, and then back to 10.
The code segment creates two Gadget objects a and b. After executing the code segment, the object a has a status value of 3 and the object b has a status value of 3.
The code segment creates two Gadget objects a and b. After executing the code segment, the object a has a status value of 3 and the object b has a status value of 10.
4.
MULTIPLE CHOICE QUESTION
2 mins • 1 pt
Both numOunces and numSold can be accessed and updated.
Both numOunces and numSold can be accessed, but only numOunces can be updated.
Both numOunces and numSold can be accessed, but only numSold can be updated.
numSold can be accessed but not updated; numOunces cannot be accessed or updated.
numSold can be accessed and updated; numOunces cannot be accessed or updated.
5.
MULTIPLE CHOICE QUESTION
2 mins • 1 pt
The following class is used to represent shipping containers. Each container can hold a number of units equal to unitsPerContainer.
The following code segment appears in a method in a class other than UnitsHandler. Assume that no other code segments have created or modified UnitsHandler objects.
UnitsHandler large = new UnitsHandler(100);
UnitsHandler.update(8);
Which of the following best describes the behavior of the code segment?
The code segment does not compile, because it is not possible to create the object large from outside the UnitsHandler class.
The code segment does not compile, because it attempts to change the values of private variables from outside the UnitsHandler class.
The code segment does not compile, because the update method should be called on the object large instead of on the UnitsHandler class.
The code segment creates a UnitsHandler object called large and sets the static variable unitsPerContainer to 100. The static variables containers and totalUnits each retain the default value 0.
The code segment creates a UnitsHandler object called large and sets the static variables unitsPerContainer, containers, and totalUnits to 100, 8, and 800, respectively.
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?
Similar Resources on Wayground
10 questions
python
Quiz
•
10th Grade
10 questions
Information processing cycle
Quiz
•
10th Grade
10 questions
Arithmetic Operators, Casting, Concatenation
Quiz
•
9th - 12th Grade
10 questions
Latency and Bandwidth
Quiz
•
10th - 11th Grade
10 questions
Scratch (28th March)
Quiz
•
KG - University
10 questions
Drawing tools safety procedure
Quiz
•
10th Grade
10 questions
Bitmap v Vector Images
Quiz
•
KG - University
10 questions
R082 Book Cover Assets planning
Quiz
•
7th - 12th Grade
Popular Resources on Wayground
7 questions
History of Valentine's Day
Interactive video
•
4th Grade
15 questions
Fractions on a Number Line
Quiz
•
3rd Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
22 questions
fractions
Quiz
•
3rd Grade
15 questions
Valentine's Day Trivia
Quiz
•
3rd Grade
20 questions
Main Idea and Details
Quiz
•
5th Grade
20 questions
Context Clues
Quiz
•
6th Grade
Discover more resources for Computers
10 questions
Exploring Valentine's Day with Charlie Brown
Interactive video
•
6th - 10th Grade
18 questions
Valentines Day Trivia
Quiz
•
3rd Grade - University
20 questions
-AR -ER -IR present tense
Quiz
•
10th - 12th Grade
10 questions
Valentine's Day History and Traditions
Interactive video
•
6th - 10th Grade
21 questions
Presidents Day Trivia
Quiz
•
6th - 12th Grade
10 questions
Valentine's Day: History and Modern Celebration
Interactive video
•
9th - 12th Grade
11 questions
Valentine's Day Trivia
Quiz
•
8th - 12th Grade
10 questions
Factor Quadratic Expressions with Various Coefficients
Quiz
•
9th - 12th Grade