Are you taking CLEP classes? Try clep.ai
| preferred AP College board partner for AP classes
AP Computer Science A/Unit 2: Using Objects
Start Practice TestPractice Test
About Exam
medium Solved by 2 students

Java String Method Behavior

Mark
< Prev
Next >

Consider the following code segment.

String word = "PROGRAMMING";
int pos = word.indexOf("GRAM");
String result = word.substring(pos, pos + 4);
System.out.println(result);

Which of the following best describes what is accomplished by this code segment?

A

It finds and extracts the substring “GRAM” from the original string

B

It counts the number of characters between “GRAM” and the end of the string

C

It creates a new string by removing “GRAM” from the original string

D

It replaces all occurrences of “GRAM” with a 4-character substring

Hint
Did You Know?
Explain Why
Explain All Answers
Check Answer
Show Correct Answer
Report Question

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Total Time
Score
#1ansonjia137122 0m 00s 200
#2zgj0731041701 0m 36s -46
#3lsj0803092211 4m 03s -143
Items per page:
10
1 – 3 of 3

AI Tutor

How can I help?

APFIVE © 2020.
Email: apfive@apfive.org|Privacy Policy|