Complete the code to correctly calculate the result using operator precedence.
int result = 5 + 3 [1] 2;
The multiplication operator (*) has higher precedence than addition, so 3 * 2 is calculated first, then added to 5.
Complete the code to correctly evaluate the expression considering operator precedence.
int value = 10 - 4 [1] 2;
The multiplication operator (*) has higher precedence than subtraction, so 4 * 2 is calculated first, then subtracted from 10.
Fix the error in the expression to respect operator precedence and get the correct result.
int output = 20 / 4 [1] 2;
Division and multiplication have the same precedence and are evaluated left to right. Using subtraction (-) after division changes the result correctly.
Fill both blanks to create a map of numbers to their doubled values only if the number is greater than 3.
Map<Integer, Integer> squares = IntStream.range(1, 6) .filter(n -> n [1] 3) .boxed() .collect(Collectors.toMap(n -> n, n -> n [2] 2));
The filter uses > to select numbers greater than 3. The map doubles each number using the * operator.
Fill all three blanks to create a map of uppercase strings to their lengths only if the length is greater than 4.
Map<String, Integer> result = words.stream()
.filter(word -> word.length() [1] 4)
.collect(Collectors.toMap(word -> word.[2](), word -> word.[3]()));The filter uses > to select words longer than 4 characters. The map uses toUpperCase() for keys and length() for values.