Iteration in Programming
Which data structure is most suitable for storing unique words read from a large document while optimizing for fast membership checking?
TreeMap
HashSet
LinkedList
ArrayList
When desiring both the capability of random access and preservation of natural order in a list of strings, which collection type provides the best balance of these requirements?
LinkedList
TreeMap
ArrayList
HashSet
When initializing a String object in Java, which constructor creates an empty string?
new String(" ")
new String(null)
new String()
new String([])
Given a non-empty string str
, which function call finds its longest mirror-like substring from both ends, assuming an efficient recursive solution?
findLongestMirror(str.substring(str.length()/2))
findLongestMirror(str + str)
findLongestMirror(str)
findLongestMirror(str.substring(1))
If you want to compare two strings s1
and s2
for equality, which method should you use?
equals(s1,s2)
s1.equal(s2)
s1.equals(s2)
s1 == s2
Which loop correctly finds and prints all substrings of length three from a non-empty String variable named 'text'?
for(int j=0;j<text.length()-2;j++){System.out.println(text.charAt(j)+""+text.charAt(j+1)+text.charAt(j+2));}
for (int i = 0; i <= text.length() -3 ;i++){System.out.println(text.substring(i,i+3));}
for (int i=3;i<=text.length();i++){System.out.println(text.substring(i-3,i));}
for (int i=2;i<text.length();i++){System.out.println(text.substring(i-2,i));}
How does the "Reversing a String" algorithm work?
It finds the longest palindrome substring in a string
It removes all vowels from a string
It reverses the characters in a string by iterating through each character
It converts all lowercase letters to uppercase and vice versa

How are we doing?
Give us your feedback and let us know how we can improve
Which approach would be less efficient for concatenating n strings stored in an array when considering time complexity?
Recursively concatenating pairs of strings until one remains.
Iteratively using String's concat method in a loop for all n strings.
Using String.join with an appropriate delimiter once on all n strings.
Utilizing StringBuilder's append method in a loop for all n strings.
How does the "Check for a Substring" algorithm determine if a substring exists in a string?
It checks if the given substring is present at the beginning of the string
It checks if the given substring is equal to the entire string
It compares each substring of the desired length with the given substring
It counts the number of occurrences of the given substring in the string
How do you find the character at index 2 in a string named str?
str.charAt(2);
str.getCharAt(2);
str[2];
str.indexOf(2);