Topic 3 & 4 Practice - ArrayList and String Methods

Topic 3 & 4 Practice - ArrayList and String Methods

12th Grade

15 Qs

quiz-placeholder

Similar activities

ICT_LU3-Computer Software_League2

ICT_LU3-Computer Software_League2

10th - 12th Grade

10 Qs

Create a Website 1

Create a Website 1

KG - University

10 Qs

Parity

Parity

10th - 12th Grade

10 Qs

File Extensions

File Extensions

9th Grade - Professional Development

20 Qs

Bài 29. Nhận biết lỗi chương trình

Bài 29. Nhận biết lỗi chương trình

9th - 12th Grade

14 Qs

Internet Technologies

Internet Technologies

12th Grade

10 Qs

ARRAYS

ARRAYS

11th - 12th Grade

10 Qs

Logika & Pemrograman (ID)

Logika & Pemrograman (ID)

10th Grade - Professional Development

20 Qs

Topic 3 & 4 Practice - ArrayList and String Methods

Topic 3 & 4 Practice - ArrayList and String Methods

Assessment

Quiz

Computers

12th Grade

Practice Problem

Hard

Created by

SAMUEL KEENER

Used 3+ times

FREE Resource

AI

Enhance your content in a minute

Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...

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

Media Image

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

Media Image

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

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

By signing up, you agree to our Terms of Service & Privacy Policy

Already have an account?