Each question below shows the correct answer with a full explanation. Use these to build conceptual understanding before attempting a timed quiz.
Strings & Text ProcessingEasy
Q1. What does the length/len function return for a string?
- A.The index of the last character
- B.The memory size in bytes
- C.The number of characters in the string✓ Correct
- D.The ASCII value of the first character
Explanation
The length function returns the total number of characters in a string.
Report an error in this question
Strings & Text ProcessingEasy
Q2. How are strings typically stored in memory?
- A.As boolean value sequences
- B.As integer values in memory
- C.As an array of characters✓ Correct
- D.As floating-point numbers
Explanation
Strings are stored as sequences (arrays) of characters in memory.
Report an error in this question
Strings & Text ProcessingEasy
Q3. What is a substring?
- A.The name of a string variable only
- B.A string that contains no characters
- C.A contiguous portion of the string✓ Correct
- D.A complete copy of the entire string
Explanation
A substring is a contiguous sequence of characters within a string.
Report an error in this question
Strings & Text ProcessingEasy
Q4. What does the toUpperCase() method do?
- A.Converts all characters to lowercase
- B.Converts all characters to uppercase✓ Correct
- C.Reverses the character order fully
- D.Removes all whitespace characters
Explanation
toUpperCase() returns a new string with all alphabetic characters converted to uppercase.
Report an error in this question
Strings & Text ProcessingEasy
Q5. What is an empty string?
- A.A string with spaces only inside it
- B.An uninitialized variable with no type
- C.A null value with no reference set
- D.A string with zero characters in it✓ Correct
Explanation
An empty string is a string containing no characters, having a length of zero.
Report an error in this question
Strings & Text ProcessingEasy
Q6. What is string concatenation?
- A.Splitting a string into parts
- B.Reversing a string order
- C.Joining two or more strings✓ Correct
- D.Deleting a string entirely
Explanation
Concatenation combines two or more strings into a single string.
Report an error in this question
Strings & Text ProcessingEasy
Q7. What is the index of the first character in a string in most languages?
- A.-1
- B.2
- C.0✓ Correct
- D.1
Explanation
In most programming languages (C, Java, Python), string indexing starts at 0.
Report an error in this question
Strings & Text ProcessingMedium
Q8. What is a regular expression?
- A.A standard normal string literal value
- B.An algorithm for sorting string collections
- C.A pattern for matching and manipulating text✓ Correct
- D.A mathematical expression using operators
Explanation
A regular expression (regex) is a sequence of characters defining a search pattern for matching, finding, or replacing text.
Report an error in this question
Strings & Text ProcessingMedium
Q9. What is the difference between String, StringBuilder, and StringBuffer in Java?
- A.StringBuilder is immutable while String and StringBuffer are both mutable
- B.They are all identical in function and performance with no differences
- C.String is immutable; StringBuilder is mutable; StringBuffer is thread-safe✓ Correct
- D.StringBuffer is always the fastest option among all three implementations
Explanation
String is immutable. StringBuilder is mutable and fast but not thread-safe. StringBuffer is mutable and thread-safe but slower due to synchronization.
Report an error in this question
Strings & Text ProcessingMedium
Q10. What is the difference between mutable and immutable strings?
- A.Mutable strings always execute faster than immutable string types
- B.Immutable strings can dynamically grow in size without any limit
- C.There is no meaningful difference between the two string types
- D.Mutable strings can be modified in place; immutable ones cannot✓ Correct
Explanation
Mutable strings (e.g., StringBuilder) can be modified in place, while immutable strings (e.g., Java String) create a new object for any change.
Report an error in this question
Strings & Text ProcessingMedium
Q11. What is the String Pool in Java?
- A.A thread pool dedicated to string processing
- B.A mutable buffer for building string values
- C.A collection of string utility methods
- D.A heap area that caches string literals for reuse✓ Correct
Explanation
The String Pool is a special area in the Java heap that caches string literals, so identical string literals share the same reference.
Report an error in this question
Strings & Text ProcessingMedium
Q12. What does the split() method do?
- A.Divides a string into an array of parts✓ Correct
- B.Joins multiple strings into one
- C.Converts string to a character array
- D.Removes specified characters from string
Explanation
split() divides a string into an array of substrings using a specified delimiter or regular expression.
Report an error in this question
Strings & Text ProcessingEasy
Q13. What does the trim() method do?
- A.Removes leading and trailing whitespace✓ Correct
- B.Converts all characters to lowercase form
- C.Removes every character from the string
- D.Splits the string at every space character
Explanation
trim() removes whitespace characters from both the beginning and end of a string.
Report an error in this question
Strings & Text ProcessingEasy
Q14. How do you compare strings in Java?
- A.Using the == operator directly
- B.Using the + concatenation operator
- C.Using the > comparison operator
- D.Using the equals() method call✓ Correct
Explanation
In Java, equals() compares string content, while == compares object references.
Report an error in this question
Strings & Text ProcessingMedium
Q15. What is string interpolation?
- A.Converting strings to their numeric equivalents
- B.Splitting strings by a delimiter character
- C.Comparing two strings for equality or ordering
- D.Embedding variables directly within a string✓ Correct
Explanation
String interpolation allows embedding variable values or expressions directly in a string, e.g., f-strings in Python or template literals in JavaScript.
Report an error in this question
Strings & Text ProcessingEasy
Q16. What is a character in programming?
- A.A string of exactly two characters
- B.A numeric whole number data type
- C.A single symbol like a letter or digit✓ Correct
- D.A boolean true or false data value
Explanation
A character is a single symbol, typically represented by the char data type.
Report an error in this question
Strings & Text ProcessingMedium
Q17. What is Unicode?
- A.A type of data encryption algorithm
- B.An extension of the ASCII character set
- C.A universal character encoding standard✓ Correct
- D.A specific font type used in displays
Explanation
Unicode is a standard that assigns unique code points to characters from virtually all writing systems worldwide.
Report an error in this question
Strings & Text ProcessingHard
Q18. What is the KMP (Knuth-Morris-Pratt) string matching algorithm?
- A.A comparison-based sorting algorithm for arrays
- B.A tree traversal algorithm for binary search trees
- C.A linear-time string matcher using a failure function✓ Correct
- D.A hashing algorithm for generating unique hash codes
Explanation
KMP achieves O(n+m) string matching by precomputing a partial match table to skip unnecessary character comparisons.
Report an error in this question
Strings & Text ProcessingMedium
Q19. What is string encoding (like UTF-8)?
- A.Compressing a string to reduce storage size
- B.Encrypting a string for secure transmission
- C.Converting a string value into an integer
- D.Representing Unicode characters as byte sequences✓ Correct
Explanation
UTF-8 is a variable-length encoding that represents each Unicode code point as 1 to 4 bytes, backward-compatible with ASCII.
Report an error in this question
Strings & Text ProcessingHard
Q20. What is the time complexity of naive string matching?
- A.O(n*m)✓ Correct
- B.O(log n)
- C.O(n)
- D.O(n^2)
Explanation
Naive string matching compares the pattern at each position in the text, resulting in O(n*m) worst-case time complexity.
Report an error in this question
Strings & Text ProcessingMedium
Q21. What is the difference between ASCII and Unicode?
- A.ASCII supports many more characters than Unicode ever can
- B.Unicode is the older standard that was developed before ASCII
- C.They are exactly the same encoding standard with no differences
- D.ASCII uses 7 bits for 128 chars; Unicode supports over 143,000✓ Correct
Explanation
ASCII encodes 128 characters using 7 bits, while Unicode supports characters from all writing systems using variable-length encoding.
Report an error in this question
Strings & Text ProcessingMedium
Q22. What is a string builder pattern and when should you use it?
- A.A design pattern for constructing user interface strings
- B.A utility tool for building complex regular expressions
- C.A parser that transforms strings into structured data types
- D.Using a mutable class for efficient repeated concatenation✓ Correct
Explanation
When performing many string concatenations in a loop, StringBuilder is more efficient because it avoids creating many intermediate immutable string objects.
Report an error in this question
Strings & Text ProcessingHard
Q23. What is string interning?
- A.Compressing strings to reduce their memory size
- B.Storing one copy of each distinct string value✓ Correct
- C.Encrypting strings for secure data transmission
- D.Storing strings in a temporary memory buffer
Explanation
String interning stores a single copy of each unique string value, allowing equality checks via reference comparison instead of character comparison.
Report an error in this question
Strings & Text ProcessingHard
Q24. What is the Rabin-Karp algorithm?
- A.A graph traversal algorithm for shortest paths
- B.A string matcher using hashing for efficient search✓ Correct
- C.A comparison-based sorting algorithm for collections
- D.A compression algorithm for reducing data file sizes
Explanation
Rabin-Karp uses rolling hash functions to efficiently compare the pattern with substrings of the text, achieving O(n+m) expected time.
Report an error in this question
Strings & Text ProcessingHard
Q25. What is a rope data structure for strings?
- A.A contiguous array of individual character values
- B.A hash map that stores character frequency counts
- C.A singly linked list of character nodes
- D.A balanced tree for efficient long string operations✓ Correct
Explanation
A rope is a binary tree where leaves contain short strings, enabling efficient concatenation, insertion, and deletion on very long strings.
Report an error in this question
Strings & Text ProcessingHard
Q26. What is the Boyer-Moore string search algorithm's key insight?
- A.Start comparing from the beginning of the pattern each time
- B.Use hashing to compare the pattern against every position
- C.Compare every single character without skipping any at all
- D.Start from pattern end and use heuristics to skip sections✓ Correct
Explanation
Boyer-Moore compares the pattern from right to left and uses precomputed heuristics to skip large portions of the text.
Report an error in this question
Strings & Text ProcessingHard
Q27. What is the difference between UTF-8, UTF-16, and UTF-32?
- A.UTF-32 uses the least amount of storage space per character overall
- B.They are all identical encoding formats with no differences at all
- C.UTF-8 uses 1-4 bytes, UTF-16 uses 2-4 bytes, UTF-32 uses exactly 4✓ Correct
- D.UTF-8 is a fixed-width encoding that always uses exactly one byte
Explanation
UTF-8 uses 1-4 bytes (variable), UTF-16 uses 2 or 4 bytes, and UTF-32 uses exactly 4 bytes per character.
Report an error in this question
Strings & Text ProcessingHard
Q28. What are surrogate pairs in UTF-16?
- A.Duplicate characters stored in the encoding table
- B.Error codes returned by the UTF-16 encoding process
- C.Pairs of 16-bit units for characters beyond the BMP✓ Correct
- D.Paired delimiter characters used in string literals
Explanation
Characters with code points above U+FFFF require two 16-bit code units (a high surrogate and a low surrogate) in UTF-16 encoding.
Report an error in this question
Strings & Text ProcessingHard
Q29. What is a trie (prefix tree) and how does it relate to strings?
- A.A linked list that stores strings in sequential memory order
- B.A standard binary search tree data structure
- C.A hash table that maps string keys to their computed values
- D.A tree where each node represents a character for prefix search✓ Correct
Explanation
A trie stores strings character by character in a tree structure, enabling efficient prefix searches, autocomplete, and dictionary lookups.
Report an error in this question
Strings & Text ProcessingHard
Q30. What is the Levenshtein distance?
- A.The total length of a string in characters
- B.The count of matching characters between strings
- C.The byte size of a string in memory allocation
- D.The minimum single-character edits between strings✓ Correct
Explanation
Levenshtein distance measures the minimum number of edit operations needed to change one string into another, used in spell checking and fuzzy matching.
Report an error in this question