Search Header Logo

Strings Java

Authored by Manoj R

Computers

12th Grade

Used 1+ times

Strings Java
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

16 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the correct way to declare and initialize a String variable in Java?

String str; str = 'Hello';

String str = new String('Hello');

String str = "Hello";

String str = new String(); str = 'Hello';

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How can you concatenate two Strings in Java?

string1.append(string2)

string1.concat(string2)

string1 + string2

string1.add(string2)

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What does the charAt method in Java return?

The length of the string

The character at the specified index

The index of the specified character

A boolean value

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How can you extract a substring from a String in Java?

string.extract(startIndex, endIndex)

string.getSubstring(startIndex, endIndex)

substring.extract(startIndex, endIndex)

string.substring(startIndex, endIndex)

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which method is used to search for a specific character in a String in Java?

searchChar()

findChar()

locateChar()

indexOf()

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How can you replace a specific character in a String in Java?

str.replace('a', 'b', 1);

str.replaceFirst('a', 'b');

str.replaceAll('a', 'b');

str = str.replace('a', 'b');

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which class is preferred for manipulating mutable strings in Java?

String

StringBuilder

StringBuffer

StringWriter

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?