Quiz Space

Programming Concepts using Java · End Term · 30 Apr 2023 · January 2023 term · Set QPD1-S2

Question 11: Consider the code given below. What will the output be?

Question 11

+4 marksOne correct option

Consider the code given below.

java
import java.util.*;
import java.util.stream.*;
class Student{
String id;
double cgpa;
//Constructor to initialize instance variables
//Method toString() to return id of the student
}
public class CollectingTest {
public static void main(String[] args){
var sArr = new ArrayList<Student>();
sArr.add(new Student("ID6789", 9.75));
sArr.add(new Student("ID5345", 6.75));
sArr.add(new Student("ID4378", 8.00));
sArr.add(new Student("ID7790", 8.45));
Map<Boolean, List<Student>> stuMap;
stuMap = sArr.stream()
.collect(Collectors.partitioningBy(s->s.cgpa >= 8.00));
System.out.println(stuMap.get(true));
System.out.println(stuMap.get(false));
}
}

What will the output be?

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

Correct answer

  • C

Question 11 of 23 in the IIT Madras BS Programming Concepts using Java (Java) End Term paper sat on 30 Apr 2023, in the January 2023 term (IIT M DIPLOMA ET1 EXAM QPD1 S2 30 Apr 2023). It carries 4 marks.

More questions from this paper

  1. Q1Consider the Java code given below. During execution of Line 14 in the above code, the activation record of which metho…
  2. Q2Consider the following code. What will the output be?
  3. Q3Consider the code given below Choose the correct option.
  4. Q4Consider the code given below that checks whether two laptops are the same. Method equals is overridden to compare two …
  5. Q5Consider the Java code given below, and answer the question that follows: Choose the correct option.
  6. Q6Consider the code given below. What will the output be?
  7. Q7Consider the code given below. What will the output be?
  8. Q8Consider the Java code given below. What will the output be?
  9. Q9Consider the Java code given below. What will the output be?
  10. Q10Consider the code given below. Choose the correct option.
  11. Q12Consider the code given below.\ Assume that file "data.txt" exists and contains the following text.\ I love my country\…
  12. Q13Consider the Java code given below. Choose the correct option when the program is executed as:\ java -ea AssertionTest
  13. Q14Figure question
  14. Q15Consider the code given below. What will be the possible output?
  15. Q16Consider the code given below. Choose the correct option to be filled in place of CODE BLOCK so that the output is: Cha…
  16. Q17Consider the code given below. Choose the correct option/s
  17. Q18Consider the Java code given below that prints the recharge time of each charger in a list of chargers. From among the …
  18. Q19Figure question
  19. Q20Consider the code given below. From among the options given below, which are possible outputs of the given code?
  20. Q21Consider the code given below. Identify the appropriate option(s) to fill in the blank at LINE 1, such that the output …
  21. Q22Consider the code given below. If the code given above produces the output: Apples\ Grapes\ Apples\ Grapes What should …
  22. Q23Consider the Java code given below. Choose the correct option(s) to be filled in place of CODE BLOCK so that the progra…