11/8/23, 8:20 PM WEEK_12_MCQ: Attempt review
Dashboard / My courses / CS19342-OOPP-2022 / 12 - List, Set / WEEK_12_MCQ
Started on Friday, 3 November 2023, 7:35 PM
State Finished
Completed on Friday, 3 November 2023, 8:03 PM
Time taken 28 mins 10 secs
Marks 7.00/20.00
Grade 12.25 out of 35.00 (35%)
Name KEERTHANA M G CSE-B
Question 1
Correct
Mark 1.00 out of 1.00
What will be the output of the following Java code snippet?
1. public class Test
2. {
3. public static void main(String[] args)
4. {
5. Set s = new HashSet();
6. s.add(new Long(10));
7. s.add(new Integer(10));
8. for(Object object : s)
9. {
10. System.out.println("test - "+object);
11. }
12. }
13. }
a. Runtime Exception
b. Test – 10
c. Compilation Failure
d. Test - 10
Test - 10
Your answer is correct.
The correct answer is:
Test - 10
Test - 10
https://www.rajalakshmicolleges.net/moodle/mod/quiz/review.php?attempt=735031&cmid=6322 1/11
11/8/23, 8:20 PM WEEK_12_MCQ: Attempt review
Question 2
Incorrect
Mark 0.00 out of 1.00
How to remove duplicates from List?
a. HashSet<String> listToSet = duplicateList.toSet();
b. HashSet<String> listToSet = duplicateList.getSet();
c. HashSet<String> listToSet = Collections.convertToSet(duplicateList);
d. HashSet<String> listToSet = new HashSet<String>(duplicateList);
Your answer is incorrect.
The correct answer is:
HashSet<String> listToSet = new HashSet<String>(duplicateList);
Question 3
Incorrect
Mark 0.00 out of 1.00
What differentiates a circular linked list from a normal linked list?
a. You cannot have the ‘next’ pointer point to null in a circular linked list
b. It is faster to traverse the circular linked list
c. You may or may not have the ‘next’ pointer point to null in a circular linked list
d. Head node is known in circular linked list
Your answer is incorrect.
The correct answer is:
You may or may not have the ‘next’ pointer point to null in a circular linked list
https://www.rajalakshmicolleges.net/moodle/mod/quiz/review.php?attempt=735031&cmid=6322 2/11
11/8/23, 8:20 PM WEEK_12_MCQ: Attempt review
Question 4
Incorrect
Mark 0.00 out of 1.00
What will be the output of the following Java code snippet?
1. import java.util.*;
2. class Linkedlist
3. {
4. public static void main(String args[])
5. {
6. LinkedList obj = new LinkedList();
7. obj.add("A");
8. obj.add("B");
9. obj.add("C");
10. obj.addFirst("D");
11. System.out.println(obj);
12. }
13. }
a. [D, A, B, C]
b. [D, B, C]
c. [A, B, C, D]
d. [A, B, C]
Your answer is incorrect.
The correct answer is:
[D, A, B, C]
Question 5
Correct
Mark 1.00 out of 1.00
Which of these method of HashSet class is used to add elements to its object?
a. Add()
b. add()
c. addFirst()
d. insert()
Your answer is correct.
The correct answer is:
add()
https://www.rajalakshmicolleges.net/moodle/mod/quiz/review.php?attempt=735031&cmid=6322 3/11
11/8/23, 8:20 PM WEEK_12_MCQ: Attempt review
Question 6
Correct
Mark 1.00 out of 1.00
Which of these standard collection classes implements a linked list data structure?
a. LinkedList
b. AbstractList
c. AbstractSet
d. HashSet
Your answer is correct.
The correct answer is:
LinkedList
Question 7
Correct
Mark 1.00 out of 1.00
Which of this method is used to change an element in a LinkedList Object?
a. redo()
b. change()
c. set()
d. add()
Your answer is correct.
The correct answer is:
set()
Question 8
Incorrect
Mark 0.00 out of 1.00
Which of these methods can be used to delete the last element in a LinkedList object?
a. delete()
b. remove()
c. removeLast()
d. deleteLast()
Your answer is incorrect.
The correct answer is:
removeLast()
https://www.rajalakshmicolleges.net/moodle/mod/quiz/review.php?attempt=735031&cmid=6322 4/11
11/8/23, 8:20 PM WEEK_12_MCQ: Attempt review
Question 9
Incorrect
Mark 0.00 out of 1.00
What is the output of this program?
import java.util.*;
class Output
{
public static void main(String args[])
ArrayList obj = new ArrayList();
obj.add("A");
obj.add(0, "B");
System.out.println(obj.size());
a. 2
b. 0
c. 3
d. 1
Your answer is incorrect.
The correct answer is:
2
Question 10
Correct
Mark 1.00 out of 1.00
How to create a TreeSet that stores values in descending order ?
a. TreeSet<Integer> set = new TreeSet<>(Collection.orderReverse());
b. TreeSet<Integer> set = new TreeSet<>().reverse();
c. TreeSet<Integer> set = new TreeSet<>().reverseCollection();
d. TreeSet<Integer> set = new TreeSet<>(Collections.reverseOrder());
Your answer is correct.
The correct answer is:
TreeSet<Integer> set = new TreeSet<>(Collections.reverseOrder());
https://www.rajalakshmicolleges.net/moodle/mod/quiz/review.php?attempt=735031&cmid=6322 5/11
11/8/23, 8:20 PM WEEK_12_MCQ: Attempt review
Question 11
Incorrect
Mark 0.00 out of 1.00
You need to store elements in a collection that guarantees that no duplicates are stored and all elements can be accessed in natural
order. Which interface provides that capability?
a. java.util.Collection
b. java.util.Set
c. java.util.Map
d. java.util.List
Your answer is incorrect.
The correct answer is:
java.util.Set
Question 12
Incorrect
Mark 0.00 out of 1.00
What is the difference between TreeSet and SortedSet?
a. SortedSet is an interface; TreeSet is a concrete class
b. SortedSet is more efficient than TreeSet
c. TreeSet is more efficient than SortedSet
d. TreeSet is an interface; SortedSet is a concrete class
Your answer is incorrect.
The correct answer is:
SortedSet is an interface; TreeSet is a concrete class
https://www.rajalakshmicolleges.net/moodle/mod/quiz/review.php?attempt=735031&cmid=6322 6/11
11/8/23, 8:20 PM WEEK_12_MCQ: Attempt review
Question 13
Incorrect
Mark 0.00 out of 1.00
What will be the output of the following Java program?
1. import java.util.*;
2. class Output
3. {
4. public static void main(String args[])
5. {
6. TreeSet t = new TreeSet();
7. t.add("3");
8. t.add("9");
9. t.add("1");
10. t.add("4");
11. t.add("8");
12. System.out.println(t);
13. }
14. }
a. [9, 8, 4, 3, 1]
b. [1, 3, 5, 8, 9]
c. [1, 3, 4, 8, 9]
d. [3, 4, 1, 8, 9]
Your answer is incorrect.
The correct answer is:
[1, 3, 4, 8, 9]
https://www.rajalakshmicolleges.net/moodle/mod/quiz/review.php?attempt=735031&cmid=6322 7/11
11/8/23, 8:20 PM WEEK_12_MCQ: Attempt review
Question 14
Incorrect
Mark 0.00 out of 1.00
What will be the output of the following Java program?
1. import java.util.*;
2. class Output
3. {
4. public static void main(String args[])
5. {
6. ArrayList obj = new ArrayList();
7. obj.add("A");
8. obj.add(0, "B");
9. System.out.println(obj.size());
10. }
11. }
a. Any Garbage Value
b. 1
c. 0
d. 2
Your answer is incorrect.
The correct answer is:
2
https://www.rajalakshmicolleges.net/moodle/mod/quiz/review.php?attempt=735031&cmid=6322 8/11
11/8/23, 8:20 PM WEEK_12_MCQ: Attempt review
Question 15
Incorrect
Mark 0.00 out of 1.00
What will be the output of the following Java program?
1. import java.util.*;
2. class Linkedlist
3. {
4. public static void main(String args[])
5. {
6. LinkedList obj = new LinkedList();
7. obj.add("A");
8. obj.add("B");
9. obj.add("C");
10. obj.removeFirst();
11. System.out.println(obj);
12. }
13. }
a. [A, B]
b. [A, B, C, D]
c. [A, B, C]
d. [B, C]
Your answer is incorrect.
The correct answer is:
[B, C]
Question 16
Correct
Mark 1.00 out of 1.00
Which of the following can be used as stack,queue,list?
a. All of the mentioned
b. LinkedHashMap
c. LinkedList
d. LinkedHashSet
Your answer is correct.
The correct answer is:
LinkedList
https://www.rajalakshmicolleges.net/moodle/mod/quiz/review.php?attempt=735031&cmid=6322 9/11
11/8/23, 8:20 PM WEEK_12_MCQ: Attempt review
Question 17
Incorrect
Mark 0.00 out of 1.00
Which collection class allows you to grow or shrink its size and provides indexed access to its elements, but whose methods are not
synchronized?
a. java.util.ArrayList
b. java.util.List
c. java.util.LinkedHashSet
d. java.util.HashSet
Your answer is incorrect.
The correct answer is:
java.util.ArrayList
Question 18
Incorrect
Mark 0.00 out of 1.00
Since Set interface in java closely resembles the mathematical set model, which of the following operations in mathematical set model
can be implemented by the Set interface as well?
a. difference
b. All of the mentioned
c. Union
d. intersection
Your answer is incorrect.
The correct answer is:
All of the mentioned
Question 19
Correct
Mark 1.00 out of 1.00
What implementation of Iterator can traverse a collection in both directions?
a. SetIterator
b. MapIterator
c. ListIterator
d. Iterator
Your answer is correct.
The correct answer is:
ListIterator
https://www.rajalakshmicolleges.net/moodle/mod/quiz/review.php?attempt=735031&cmid=6322 10/11
11/8/23, 8:20 PM WEEK_12_MCQ: Attempt review
Question 20
Incorrect
Mark 0.00 out of 1.00
How can we remove an object from ArrayList?
a. delete() method
b. using Iterator
c. remove() method
d. remove() method and using Iterator
Your answer is incorrect.
The correct answer is:
remove() method and using Iterator
◄ IO operations
Jump to...
WEEK_12_CODING ►
https://www.rajalakshmicolleges.net/moodle/mod/quiz/review.php?attempt=735031&cmid=6322 11/11