Question 1
Consider the Java code given below that should print the names of students whose grades are between 70.0 and 90.0 (both inclusive).
import java.util.*;class Student { String name; double grade; public Student(String n, double g) { name = n; grade = g; }}public class TestGrades { public static void main(String[] args) { List<Student> students = new ArrayList<>(); students.add(new Student("Anu", 85.5)); students.add(new Student("Bindu", 92.0)); students.add(new Student("Hari", 78.0)); students.add(new Student("David", 70.0)); students.add(new Student("Hasan", 65.0)); //CODE BLOCK }}Choose the correct option(s) to fill in place of CODE BLOCK to obtain the right answer.
students.stream()
.map(s -> s.grade >= 70.0 && s.grade <= 90.0)
.forEach(s -> System.out.println(s.name));students.stream()
.filter(s -> s.grade >= 70.0 && s.grade <= 90.0)
.forEach(s -> System.out.println(s.name));students.stream()
.filter(s -> s.grade >= 70.0)
.filter(s -> s.grade <= 90.0)
.forEach(s -> System.out.println(s.name));students.stream()
.filter(s -> s.grade >= 70.0)
.map(s -> s.grade <= 90.0)
.forEach(s -> System.out.println(s.name));
