Question 1
Which of the following methods is most appropriate for checking if a string in Java starts with a specific prefix, ignoring case?
- startsWith(String prefix)
- equalsIgnoreCase(String other)
- toLowerCase().startsWith(String prefix.toLowerCase())
- regionMatches(boolean ignoreCase, int toffset, String other, int ooffset, int len)
- contains(String sequence)
Question 2
What is the purpose of using regular expressions for string validation?
- To improve the string's readability.
- To define a pattern that a string must adhere to.
- To encrypt the string for security purposes.
- To convert the string to uppercase.
- To count the number of words in a string.
Question 3
Which of the following code snippets in Python correctly removes leading and trailing whitespace from a string?
- string.remove()
- string.strip()
- string.trim()
- string.replace(' ', '')
- string.clean()
Question 4
What potential issue arises when concatenating strings repeatedly within a loop, especially with very long strings in languages like Java?
- Integer overflow.
- Inefficient memory usage due to string immutability.
- Compile-time error.
- Stack overflow.
- Increased CPU temperature.
Question 5
Which string method is generally used to split a string into a list of substrings based on a specified delimiter?
- join()
- separate()
- split()
- divide()
- segment()
Question 6
What is the purpose of escaping special characters when using regular expressions?
- To make the regex shorter.
- To prevent the characters from being interpreted as regex metacharacters.
- To improve the regex's performance.
- To make the regex easier to read.
- To automatically translate the regex into another language.
Question 7
In PHP, which function is used to find the position of the first occurrence of a substring in a string?
- strpos()
- strstr()
- substr()
- findstr()
- locate()
Question 8
Which validation check is most suitable for verifying that a string represents a valid email address?
- Checking the string length.
- Using a regular expression designed for email address validation.
- Converting the string to lowercase.
- Checking if the string contains the '@' symbol.
- Checking if the string contains numbers only.
Question 9
Which character encoding is commonly used to support a wide range of characters from different languages?
- ASCII
- UTF-8
- ISO-8859-1
- Base64
- Binary
Question 10
What is the purpose of string interpolation?
- To compress a string to reduce storage space
- To convert a string to an integer
- To substitute variables' values into a string
- To encrypt a string for security
- To reverse the order of characters in a string