Search Header Logo

String Methods

Authored by Adam Masters

Computers

12th Grade - University

Used 25+ times

String Methods
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

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

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?