Vidyalelo
Java Programming · all questions

Strings
practice.

Practice every MCQ with options. Use Show answers when you want the correct option and solution.

107

Questions

1/6

Page

Pick an option on a question to see the right answer and solution.

In Java, which class is used to represent a sequence of characters as a string?

Select an option to see the answer and solution.

What is the correct way to create a new empty String object in Java?

Select an option to see the answer and solution.

In Java, which operator is used to concatenate two strings?

Select an option to see the answer and solution.

Which of the following methods is used to compare two strings for equality in Java?

Select an option to see the answer and solution.

What does the length() method of a String object in Java return?

Select an option to see the answer and solution.

Which of the following is true about Java strings?

Select an option to see the answer and solution.

How do you convert a string to lowercase in Java?

Select an option to see the answer and solution.

What is the purpose of the charAt() method of a String object in Java?

Select an option to see the answer and solution.

Which method is used to find the index of the first occurrence of a specified character in a string in Java?

Select an option to see the answer and solution.

In Java, what is the result of the expression "Hello".substring(1, 4)?

Select an option to see the answer and solution.

What is the purpose of the trim() method of a String object in Java?

Select an option to see the answer and solution.

Which of the following methods is used to replace all occurrences of a specified character in a string in Java?

Select an option to see the answer and solution.

What is the correct way to check if a string starts with a specific prefix in Java?

Select an option to see the answer and solution.

Which method is used to split a string into an array of substrings based on a specified delimiter in Java?

Select an option to see the answer and solution.

In Java, what is the purpose of the endsWith() method of a String object?

Select an option to see the answer and solution.

What method is used to convert an integer to a string in Java?

Select an option to see the answer and solution.

Which of the following is the correct way to compare two strings in a case-insensitive manner in Java?

Select an option to see the answer and solution.

In Java, what does the concat() method of a String object do?

Select an option to see the answer and solution.

How do you find the last index of a specified character in a string in Java?

Select an option to see the answer and solution.

What is the result of the expression "Java".replace("a", "o") in Java?

Select an option to see the answer and solution.