Quiz Space

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

Question 23: Consider the Java code given below. Choose the correct o…

Question 23

+5 marksOne or more correct options

Consider the Java code given below.

java
import java.util.*;
public class SetTest {
public static void main(String[] args) {
var list = new LinkedList<String>();
list.add("Modern");
list.add("Application");
list.add("Development");
list.add("Development");
//CODE BLOCK
for(String str:list) {
set1.add(str);
set2.add(str);
}
for(String str:set1)
System.out.print(str+" ");
System.out.println();
for(String str:set2)
System.out.print(str+" ");
}
}

Choose the correct option(s) to be filled in place of CODE BLOCK so that the program always generates the following output:

Application Development Modern
Modern Application Development

Select all that apply.

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

Correct answer

  • B

Question 23 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 5 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. Q11Consider the code given below. What will the output be?
  12. Q12Consider the code given below.\ Assume that file "data.txt" exists and contains the following text.\ I love my country\…
  13. Q13Consider the Java code given below. Choose the correct option when the program is executed as:\ java -ea AssertionTest
  14. Q14Figure question
  15. Q15Consider the code given below. What will be the possible output?
  16. Q16Consider the code given below. Choose the correct option to be filled in place of CODE BLOCK so that the output is: Cha…
  17. Q17Consider the code given below. Choose the correct option/s
  18. Q18Consider the Java code given below that prints the recharge time of each charger in a list of chargers. From among the …
  19. Q19Figure question
  20. Q20Consider the code given below. From among the options given below, which are possible outputs of the given code?
  21. Q21Consider the code given below. Identify the appropriate option(s) to fill in the blank at LINE 1, such that the output …
  22. Q22Consider the code given below. If the code given above produces the output: Apples\ Grapes\ Apples\ Grapes What should …