Quiz Space

Programming Concepts using Java · Quiz 2 · 1 Dec 2024 · September 2024 term

Question 11: Consider the Java code given below. What will the output…

Question 11

+7 marksOne correct option

Consider the Java code given below.

java
import java.util.*;
import java.util.stream.*;
public class MyClass {
public static void main(String args[]) {
List<Integer> numbers = new ArrayList<>();
numbers.add(2);
numbers.add(8);
numbers.add(5);
numbers.add(12);
numbers.add(15);
Stream<Integer> filteredNumbers = numbers.stream()
.filter(n -> n % 2 == 0)
.map(n -> n * 2);
filteredNumbers.forEach(System.out::println);
}
}

What will the output be?

  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • D

Question 11 of 15 in the IIT Madras BS Programming Concepts using Java (Java) Quiz 2 paper sat on 1 Dec 2024, in the September 2024 term (IIT M DIPLOMA AN EXAM QDD2 01 Dec 2024). It carries 7 marks.

More questions from this paper

  1. Q1Consider the Java code given below that prints the price of laptops. From among the options, identify the appropriate f…
  2. Q2Consider the Java code given below. Choose the correct option.
  3. Q3The following code maps a set of athletes names to the number of medals they have won and categorizes the athletes base…
  4. Q4Consider the Java code given below. What will the output be?
  5. Q5Consider the Java code given below that prints the highest purchased amount among a set of given Buyer objects. From am…
  6. Q6Consider the Java code given below. Choose the correct option.
  7. Q7Consider two Java files located in the same package as shown below. A.java: B.java Choose the correct option.
  8. Q8Consider the Java code given below. Identify the first assert statement that throws the AssertionError when the class i…
  9. Q9Consider the Java code given below. Identify the appropriate option to fill in place of LINE 1 such that the output is:
  10. Q10Consider the Java code given below. Choose the correct option to be filled in place of LINE 1 so that the output is:
  11. Q12Consider the Java code given below. Choose the correct option to fill in the CODE BLOCK to add the name and average exp…
  12. Q13Consider the Java code given below. Choose the correct option.
  13. Q14Consider the following Java code. What will the output be?
  14. Q15Consider the Java code given below that should print the names of vehicles whose mileage is between 15.0 and 25.0 (both…