String Methods

String Methods

12th Grade - University

9 Qs

quiz-placeholder

Similar activities

Java Static

Java Static

University

10 Qs

AP CSA Unit 1 & 2 Review

AP CSA Unit 1 & 2 Review

9th - 12th Grade

10 Qs

Java Arrays

Java Arrays

University

10 Qs

java operators

java operators

University

10 Qs

Java Control Flow statements

Java Control Flow statements

University

10 Qs

javaquizvivek

javaquizvivek

University

12 Qs

Java String Methods

Java String Methods

12th Grade - University

9 Qs

Coding Strings

Coding Strings

12th Grade - University

9 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());