Search Header Logo

AP CSA Strings Review

Authored by Anthony Villanueva

Computers

12th Grade

Used 19+ times

AP CSA Strings Review
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

10 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

15 mins • 1 pt

Given the following code segment, which of the following is true?


String s1 = new String("Hi There");

String s2 = new String("Hi There");

String s3 = s1;


I. (s1 == s2)

II. (s1.equals(s2))

III. (s1 == s3)

IV. (s2.equals(s3))

II and IV

II, III, and IV

I, II, III, IV

II only

IV only

2.

MULTIPLE CHOICE QUESTION

5 mins • 1 pt

What does the following code print?


System.out.println("13" + 5 + 3);

21

1353

It will give a run-time error

138

It will give a compile-time error

Check MeCompare me

3.

MULTIPLE CHOICE QUESTION

5 mins • 1 pt

After the following code is executed, which of I, II and/or III will evaluate to true?


String s1 = "xyz";

String s2 = s1;

String s3 = s2;


I. s1.equals(s3)

II. s1 == s2

III. s1 == s3

I, II, III

I only

II only

III only

II and III only

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is output from the following code?


String s = "Georgia Tech";

String s1 = s.substring(0,7);

String s2 = s1.substring(2);

String s3 = s2.substring(0,3);

System.out.println(s3);

org

eor

eorg

orgi

You will get an index out of bounds exception

5.

MULTIPLE CHOICE QUESTION

5 mins • 1 pt

Given the following code segment, what is the value of s1 after the code executes?


String s1 = "Hi There";

String s2 = s1;

String s3 = s2;

String s4 = s1;

s2 = s2.toLowerCase();

s3 = s3.toUpperCase();

s4 = null;

null

hi there

HI THERE

Hi There

hI tHERE

6.

MULTIPLE CHOICE QUESTION

5 mins • 1 pt

There is a method called checkString that determines whether a string is the same forwards and backwards. The following data sets can be used for testing the method. What advantage does Data Set 2 have over Data Set 1?


Data Set 1 Data Set 2

aba bcb

abba bcd

aBa

Data Set 2 contains one string which should return true and one that should return false.

All strings in Data Set 2 have the same number of characters.

The strings in Data Set 2 are all lowercase

Data Set 2 contains fewer values than Data Set 1.

There are no advantages.

7.

MULTIPLE CHOICE QUESTION

5 mins • 1 pt

Given the following code segment, what is in the string referenced by s1?


String s1 = "xy";

String s2 = s1;

s1 = s1 + s2 + "z";

xyz

xyxyz

xy xy z

xy z

z

Access all questions and much more by creating a free account

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

Already have an account?