Quiz Space

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

Question 7: Consider the code given below. Choose the correct option.

Question 7

+4 marksOne correct option

Consider the code given below.

java
import java.util.*;
public class MapTest {
public static void main(String[] args) {
var batsmen= new LinkedHashMap<String,Integer>();
batsmen.put("Sachin", 100);
batsmen.put("Sachin", 55 + batsmen.getOrDefault("Sachin", 0));
batsmen.put("Sehwag", 100);
batsmen.put("Sehwag", 55);
for(Map.Entry<String, Integer> obj1:batsmen.entrySet())
System.out.println(obj1.getKey()+":"+obj1.getValue());
}
}

Choose the correct option.

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

Correct answer

  • D

Question 7 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 8 in the above code, the activation record of which method…
  2. Q2Consider the following code. Consider 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 rectangles are the same. Method equals is overridden to compare t…
  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. Q8Consider the Java code given below. What will the output be?
  8. Q9Consider the Java code given below. What will the output be?
  9. Q10Consider the code given below. Choose the correct option.
  10. Q11Consider the code given below. Choose the correct option.
  11. Q12Consider the code given below.\ Assume that file "abc.txt" exists and contains the following text.\ Hello IITM students…
  12. Q13Consider the Java code given below.\ You may make use of the description given below.\ The logarithm of a number n to t…
  13. Q14Consider the Java program given below.
  14. Q15Consider the Java program given below. What will the output be?
  15. Q16Consider the code given below. Choose the correct option to be filled in place of CODE BLOCK so that the output is: Sto…
  16. Q17Consider the code given below. Choose the correct option/s
  17. Q18Consider the Java code given below that prints the seating capacity of each vehicle in a list of vehicles. From among t…
  18. Q19Which of the following statements counts the number of integers between 100 and 150 (including 100 and 150) that are no…
  19. Q20Consider the code given below. Choose all the options that would NEVER occur as a result of execution of this 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: India\ Hyderabad\ India\ Hyderabad What sho…
  22. Q23Consider the Java code given below. Choose the correct option(s) to be filled in place of CODE BLOCK so that the progra…