Topic 3 & 4 Practice - ArrayList and String Methods

Quiz
•
Computers
•
12th Grade
•
Hard
SAMUEL KEENER
Used 3+ times
FREE Resource
15 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Consider the following code segment.
String oldStr = "ABCDEF";
String newStr = oldStr.substring(1, 3) + oldStr.substring(4);
System.out.println(newStr);
What is printed as a result of executing the code segment?
BCE
BCDE
BCEF
BCDEF
ABCDEF
2.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Consider the following code segment.
ArrayList<String> items = new ArrayList<String>();
items.add("A");
items.add("B");
items.add("C");
items.add(0, "D");
items.remove(3);
items.add(0, "E");
System.out.println(items);
What is printed as a result of executing the code segment?
[A, B, C, E]
[A, B, D, E]
[E, D, A, B]
[E, D, A, C]
[E, D, C, B]
3.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Consider the following code segment.
String temp = "comp";
System.out.print(temp.substring(0) + " " +
temp.substring(1) + " " +
temp.substring(2) + " " +
temp.substring(3));
What is printed when the code segment is executed?
comp
c o m p
comp com co c
comp omp mp p
comp comp comp comp
4.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Consider the following code segment.
String str = "CompSci";
System.out.println(str.substring(0, 3));
int num = str.length();
What is the value of num when the code segment is executed?
3
4
5
6
7
5.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Which code segment should go in the blank so that count is equal to the number of times "whoa" occurs in str?
pos>0
pos>=0
pos<0
pos<=0
pos==0
6.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
int p = "Go Paw Patrol!".indexOf("p");
What is the value of p?
0
4
3
-1
This code will not compile.
7.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Which code segment should go in the blank so that count is equal to the number of times "whoa" occurs in str?
str.length() -2
str.length() -4
str.length() - 3
str.length() - 1
str.length()
Create a free account and access millions of resources
Similar Resources on Wayground
18 questions
GCSE Computer Science Data types

Quiz
•
10th - 12th Grade
20 questions
The String Class

Quiz
•
12th Grade
13 questions
APCSA Unit 3 Review

Quiz
•
9th - 12th Grade
20 questions
Unit 6 ArrayLists and String Methods

Quiz
•
9th - 12th Grade
10 questions
Python Boolean and If

Quiz
•
9th - 12th Grade
13 questions
Unit 4 AP CSA Review

Quiz
•
12th Grade
16 questions
Database Query

Quiz
•
11th - 12th Grade
15 questions
Python Revision Tour - I

Quiz
•
12th Grade
Popular Resources on Wayground
10 questions
SR&R 2025-2026 Practice Quiz

Quiz
•
6th - 8th Grade
30 questions
Review of Grade Level Rules WJH

Quiz
•
6th - 8th Grade
6 questions
PRIDE in the Hallways and Bathrooms

Lesson
•
12th Grade
10 questions
Lab Safety Procedures and Guidelines

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

Quiz
•
3rd Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
11 questions
All about me

Quiz
•
Professional Development
15 questions
Subtracting Integers

Quiz
•
7th Grade
Discover more resources for Computers
6 questions
PRIDE in the Hallways and Bathrooms

Lesson
•
12th Grade
20 questions
Lab Safety and Lab Equipment

Quiz
•
9th - 12th Grade
7 questions
EAHS PBIS Lesson- Bathroom

Lesson
•
9th - 12th Grade
57 questions
How well do YOU know Neuwirth?

Quiz
•
9th - 12th Grade
20 questions
Getting to know YOU icebreaker activity!

Quiz
•
6th - 12th Grade
6 questions
Secondary Safety Quiz

Lesson
•
9th - 12th Grade
4 questions
Study Skills

Lesson
•
5th - 12th Grade
15 questions
Let's Take a Poll...

Quiz
•
9th Grade - University