AP CSA 5.6/5.7 (Methods & Static)

Quiz
•
Computers
•
10th Grade
•
Hard
Herman Galioulline
Used 19+ times
FREE Resource
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.
Similar Resources on Wayground
7 questions
OCR Computer Science 2.3 Testing

Quiz
•
8th - 11th Grade
10 questions
WJEC 1.7 Software Engineering

Quiz
•
9th - 10th Grade
10 questions
KS3 GCSE Computer Science (Programming / Python)

Quiz
•
7th - 11th Grade
10 questions
Computer Languages

Quiz
•
6th - 12th Grade
10 questions
CodeHS 2.10 While Loops

Quiz
•
9th - 12th Grade
5 questions
Quiz LearningX

Quiz
•
9th - 12th Grade
10 questions
What is a program slides(6:16)

Quiz
•
8th - 12th Grade
10 questions
Python

Quiz
•
10th - 11th Grade
Popular Resources on Wayground
10 questions
Video Games

Quiz
•
6th - 12th Grade
20 questions
Brand Labels

Quiz
•
5th - 12th Grade
15 questions
Core 4 of Customer Service - Student Edition

Quiz
•
6th - 8th Grade
15 questions
What is Bullying?- Bullying Lesson Series 6-12

Lesson
•
11th Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
15 questions
Subtracting Integers

Quiz
•
7th Grade
22 questions
Adding Integers

Quiz
•
6th Grade
10 questions
Exploring Digital Citizenship Essentials

Interactive video
•
6th - 10th Grade
Discover more resources for Computers
10 questions
Exploring Digital Citizenship Essentials

Interactive video
•
6th - 10th Grade
10 questions
Proper Keyboarding Techniques

Interactive video
•
6th - 10th Grade
10 questions
Understanding Computers: Hardware, Software, and Operating Systems

Interactive video
•
7th - 12th Grade
29 questions
AP CSP Unit 2 Review (Code.org)

Quiz
•
10th - 12th Grade