Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to compare two strings for equality.
Java
String a = "hello"; String b = "hello"; boolean result = a.[1](b);
🎯 Drag options to blanks, or click blank then click option
Attempts:
3 left
2fill in blank
mediumComplete the code to compare two strings ignoring case differences.
Java
String a = "Hello"; String b = "hello"; boolean result = a.[1](b);
🎯 Drag options to blanks, or click blank then click option
Attempts:
3 left
3fill in blank
hardFix the error in the code to correctly compare two strings.
Java
String a = "test"; String b = new String("test"); if (a.[1](b)) { System.out.println("Equal"); } else { System.out.println("Not equal"); }
🎯 Drag options to blanks, or click blank then click option
Attempts:
3 left
4fill in blank
hardFill both blanks to create a map of strings to their lengths, but only include strings longer than 3 characters.
Java
Map<String, Integer> lengths = words.stream()
.filter(word -> word.[1]() > 3)
.collect(Collectors.toMap(word -> word, word -> word.[2]()));🎯 Drag options to blanks, or click blank then click option
Attempts:
3 left
5fill in blank
hardFill all three blanks to create a map of uppercase strings to their lengths, including only strings longer than 4 characters.
Java
Map<String, Integer> result = words.stream()
.filter(word -> word.[1]() > 4)
.collect(Collectors.toMap(word -> word.[2](), word -> word.[3]()));🎯 Drag options to blanks, or click blank then click option
Attempts:
3 left
