Unit 6 ArrayLists and String Methods

Quiz
•
Computers
•
9th - 12th Grade
•
Medium
Terresa Uzzle
Used 3+ times
FREE Resource
20 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
The following method is intended to return an int containing the element at position index in the array numbers. For example, if numbers contains [1, 2, 3, 4, 5], then getValue(numbers, 3) should return 4.
/* missing precondition */
public int getValue(int[] numbers, int index) {
return numbers[index];
}
Which of the following is the most appropriate precondition for the method so that it does not cause an error?
/* Precondition: index > numbers.length */
/* Precondition: index >= numbers.length */
/* Precondition: 0 <= index <= numbers.length - 1 */
/* Precondition: 0 < index < numbers.length - 1 */
/* Precondition: 0 <= index <= numbers.length */
2.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Consider the following code segment.
Line 1 Integer val = Integer.MAX_VALUE;
Line 2 val = val + 1;
Line 3 System.out.println(val);
What is printed as a result of executing the code segment?
-2147483648 (equivalent to Integer.MIN_VALUE)
0
1
2147483647 (equivalent to Integer.MAX_VALUE)
2147483648
3.
MULTIPLE CHOICE QUESTION
45 sec • 1 pt
Consider the following code segment.
Line 1 int days = 365;
Line 2 Integer weeks = 52;
Line 3 int weekends = weeks;
Line 4 int months = new Integer(12);
Line 5 Integer numOfSeasons = new Integer(4);
Which variable DOES NOT have the primitive data type int?
days
weeks
months
numOfSeasons
4.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Which of the following correctly returns the total number of elements in the ArrayList population?
population.length();
population.total();
population.size();
size(population);
length(population);
5.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
nums is an ArrayList initialized with the values [3, 5, 7].
What is stored in the list nums after the following code segment is run?
nums.add(5);
nums.add(2, 4);
[3, 2, 4, 7, 5]
[3, 5, 4, 7, 5]
[8, 5, 6, 7, 5]
[3, 5, 6, 7, 9]
6.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Consider the code to the left:
What is printed as a result of executing the code sement?
racoon and koala
racoon and otter
hedgehog and otter
hedgehog and koala
Nothing is printed due to an ArrayIndexOutOfBoundsException.
7.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Consider the code to the left:
What, if anything, is printed as a result of executing the code segment?
[100, 300, 400]
[200, 300]
[300, 400]
[500, 300]
Nothing is printed because the code segment does not compile.
Create a free account and access millions of resources
Similar Resources on Wayground
20 questions
OOP Java

Quiz
•
12th Grade
22 questions
edhesive Unit 1 Vocabulary

Quiz
•
9th - 12th Grade
20 questions
Mod 2 Test

Quiz
•
9th - 12th Grade
17 questions
STEM Productions Coding and Components Assessment

Quiz
•
9th - 12th Grade
24 questions
AGAD: UNIT 4_C# & UNITY

Quiz
•
9th - 12th Grade
15 questions
AP Computer Science A Review 1

Quiz
•
10th - 12th Grade
15 questions
Python Basics Quiz

Quiz
•
9th Grade
20 questions
Computer Application Practice Quiz Class 10

Quiz
•
10th Grade
Popular Resources on Wayground
10 questions
Lab Safety Procedures and Guidelines

Interactive video
•
6th - 10th Grade
10 questions
Nouns, nouns, nouns

Quiz
•
3rd Grade
10 questions
9/11 Experience and Reflections

Interactive video
•
10th - 12th Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
11 questions
All about me

Quiz
•
Professional Development
22 questions
Adding Integers

Quiz
•
6th Grade
15 questions
Subtracting Integers

Quiz
•
7th Grade
9 questions
Tips & Tricks

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

Interactive video
•
6th - 10th Grade
10 questions
1.2 OSI & TCP IP Models Quiz

Quiz
•
10th Grade
20 questions
Digital Citizenship

Quiz
•
8th - 12th Grade
30 questions
Introduction to Computers

Quiz
•
8th - 9th Grade
35 questions
Computer Baseline Examination 2025-26

Quiz
•
9th - 12th Grade
13 questions
Problem Solving Process

Quiz
•
9th - 12th Grade
20 questions
Hardware vs. Software Quiz

Quiz
•
7th - 10th Grade
10 questions
Understanding Algorithms with Pseudocode and Flowcharts

Interactive video
•
9th - 12th Grade