Complete the code to declare an interface named Vehicle.
public interface [1] {
void move();
}The keyword interface is used to declare an interface, and Vehicle is the interface name.
Complete the code to make class Car implement the Vehicle interface.
public class Car [1] Vehicle { public void move() { System.out.println("Car is moving"); } }
In Java, a class uses the implements keyword to adopt an interface.
Fix the error in the code by completing the interface method declaration.
public interface Animal {
[1] sound();
}Interface methods must declare a return type. Here, sound() returns a String describing the sound.
Fill both blanks to create a map that maps words to their lengths only if length is greater than 3.
Map<String, Integer> wordLengths = words.stream()
.filter(word -> word.length() [1] 3)
.collect(Collectors.toMap(word -> word, word -> word.[2]()));The filter keeps words with length greater than 3 using >. The method length() gets the length of the word.
Fill all three blanks to create a map of uppercase keys to values only if value is negative.
Map<String, Integer> filteredMap = data.entrySet().stream()
.filter(entry -> entry.getValue() [1] 0)
.collect(Collectors.toMap(entry -> entry.getKey().[2](), entry -> entry.[3]()));The filter keeps entries with value less than 0 using '<'. The key is converted to uppercase with toUpperCase(). The value is accessed with getValue().