Complete the code to add two numbers and print the result.
int a = 5; int b = 3; int sum = a [1] b; System.out.println(sum);
The plus operator + adds two numbers together.
Complete the code to check if a number is greater than 10.
int number = 15; boolean isGreater = number [1] 10; System.out.println(isGreater);
The greater than operator > checks if the left value is bigger than the right.
Fix the error in the code to multiply two numbers correctly.
int x = 4; int y = 6; int product = x [1] y; System.out.println(product);
The multiplication operator * multiplies two numbers.
Fill both blanks to create a condition that checks if a number is between 5 and 10 (inclusive).
int num = 7; boolean isBetween = num [1] 5 && num [2] 10; System.out.println(isBetween);
The operator >= means 'greater than or equal to', and <= means 'less than or equal to'. Together they check if the number is between 5 and 10 inclusive.
Fill the blanks to create a map of words to their lengths, including only words longer than 3 characters.
Map<String, Integer> lengths = words.stream()
.filter(word -> word.length() [1] 3)
.collect(Collectors.toMap(word -> word, word -> word.[2]()));The filter uses > to keep words longer than 3. The key mapper uses word itself, and the value mapper uses length() to get the word length.