String Methods

String Methods

12th Grade - University

9 Qs

quiz-placeholder

Similar activities

Search for Content on Methods in Java

Search for Content on Methods in Java

11th - 12th Grade

10 Qs

While Loops and Boolean Statements

While Loops and Boolean Statements

10th - 12th Grade

10 Qs

Arrays

Arrays

10th - 12th Grade

10 Qs

Third Year Placement Training Revision Test

Third Year Placement Training Revision Test

University

10 Qs

CodeHS Unit 2

CodeHS Unit 2

11th - 12th Grade

13 Qs

String

String

10th - 12th Grade

10 Qs

CWA Java

CWA Java

10th - 12th Grade

13 Qs

BCSC0006 - Quiz 1 - Arrays

BCSC0006 - Quiz 1 - Arrays

University

10 Qs

String Methods

String Methods

Assessment

Quiz

Computers

12th Grade - University

Medium

Created by

Adam Masters

Used 24+ times

FREE Resource

9 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Returns the character found at a specified position in a string. Positions start at 0 and continue to the number of characters in the string minus 1. For example, the letter ‘h’ is at position 5.
String x = "Joseph";System.out.println(x.charAt(2));
String x = "Joe"; System.out.println(x.equals("Joe"));
String x = "Joseph"; System.out.println(x.substring(2));
String x = "Joseph"; System.out.println(x.substring(2,5));

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Returns a true or false value dependent on whether two strings are equal in value (if they match). Use the [equalsIgnoreCase()] method if the caps sensitivity of the value being matched is not important.
String x = "Joseph";System.out.println(x.charAt(2));
String x = "Joe"; System.out.println(x.equals("Joe"));
String x = "Joseph"; System.out.println(x.substring(2));
String x = "Joseph"; System.out.println(x.substring(2,5));

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Returns a substring (a section of a string) starting at a specified position. Like other methods, the positions start at 0 and continue to the number of characters in the string minus 1.
String x = "Joseph";System.out.println(x.charAt(2));
String x = "Joe"; System.out.println(x.equals("Joe"));
String x = "Joseph"; System.out.println(x.substring(2));
String x = "Joseph"; System.out.println(x.substring(2,5));

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Returns a substring (a section of string) between a start position and end position. The positions start at 0 and continue to the number of characters in the string minus 1.
String x = "Joseph";System.out.println(x.charAt(2));
String x = "Joe"; System.out.println(x.equals("Joe"));
String x = "Joseph"; System.out.println(x.substring(2));
String x = "Joseph"; System.out.println(x.substring(2,5));

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Finds a specified character or characters in a string and replaces it with a specified character or characters.
String x = "joseph"; System.out.println(x.replace("j", "J"));
String x = "Joseph"; System.out.println(x.endsWith("h"));
String x = "joseph"; System.out.println(x.toUpperCase());
String x = " joseph "; System.out.println(x.trim());

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Returns a true or false value dependent on whether the string ends/starts with a specified character or characters.
String x = "joseph"; System.out.println(x.replace("j", "J"));
String x = "Joseph"; System.out.println(x.endsWith("h"));
String x = "joseph"; System.out.println(x.toUpperCase());
String x = " joseph "; System.out.println(x.trim());

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Turns all characters in a string to either UPPER-CASE or lower-case. This can be useful when matching strings given from a user.
String x = "joseph"; System.out.println(x.replace("j", "J"));
String x = "Joseph"; System.out.println(x.endsWith("h"));
String x = "joseph"; System.out.println(x.toUpperCase());
String x = " joseph "; System.out.println(x.trim());

8.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Removes all character spaces at the beginning and end of a string. Note that this will not remove any character spaces that appear in the middle of a string.
String x = "joseph"; System.out.println(x.replace("j", "J"));
String x = "Joseph"; System.out.println(x.endsWith("h"));
String x = "joseph"; System.out.println(x.toUpperCase());
String x = " joseph "; System.out.println(x.trim());

9.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Returns a true or false value dependent on whether a string contains the values from another string. The matching string must be exact; for example, ‘SE’ or ‘s e’ would have returned false.
String x = "Joseph"; System.out.println(x.contains("se"));
String x = "Joseph"; System.out.println(x.endsWith("h"));
String x = "joseph"; System.out.println(x.toUpperCase());
String x = " joseph "; System.out.println(x.trim());