Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

CSC Exam 300 Questions with Answers: Java Collections and Lambda Expressions, Exams of Computer Science

A comprehensive set of 66 multiple-choice questions covering fundamental concepts in java collections and lambda expressions. It provides a valuable resource for students preparing for exams or seeking to solidify their understanding of these core java topics. The questions cover various aspects of java collections, including lists, sets, maps, queues, and stacks, as well as the use of lambda expressions in java programming.

Typology: Exams

2024/2025

Available from 12/22/2024

Martin-Ray-1
Martin-Ray-1 🇺🇸

5

(8)

6.1K documents

1 / 15

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Map CSC Exam 300 Questions with
Answers.
1. Which is NOT an example of software refactoring?
A. Fixing an internal bug
B. Improving performance
C. Enhancing the GUI with new buttons.
D. Modifying the internal concurrency. - Correct: ✔✔C.
Enhancing the GUI with new buttons
1. T/F: The Set collection doesn't allow duplicates - Correct:
✔✔True
2. T/F: Method overloads must have different argument lists -
Correct: ✔✔True
3. T/F: Lambda expressions can modify instance variables of the
class in which they are found - Correct: ✔✔True
4. T/F: The following statement is valid:
List<Object> aList = new ArrayList<String>(); - Correct: ✔False
5. T/F: The expression below defines Number as an upper bound:
public <U super Number> void inspect (U u) - Correct: ✔✔False
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff

Partial preview of the text

Download CSC Exam 300 Questions with Answers: Java Collections and Lambda Expressions and more Exams Computer Science in PDF only on Docsity!

Map CSC Exam 300 Questions with

Answers.

  1. Which is NOT an example of software refactoring? A. Fixing an internal bug B. Improving performance C. Enhancing the GUI with new buttons. D. Modifying the internal concurrency. - Correct: ✔✔C. Enhancing the GUI with new buttons
  2. T/F: The Set collection doesn't allow duplicates - Correct: ✔✔True
  3. T/F: Method overloads must have different argument lists - Correct: ✔✔True
  4. T/F: Lambda expressions can modify instance variables of the class in which they are found - Correct: ✔✔True
  5. T/F: The following statement is valid: List aList = new ArrayList(); - Correct: ✔✔False
  6. T/F: The expression below defines Number as an upper bound: public void inspect (U u) - Correct: ✔✔False
    1. T/F: When the sort method of Collections uses compareTo implementation for the List being sorted, there is only a single parameter referring to the List - Correct: ✔✔True
    2. T/F: According to the API, you can't pull null elements in Queues - Correct: ✔✔True
    3. T/F: A PriorityQueue is always sorted in natural order - Correct: ✔✔False
    4. T/F: Generic classes in Java can accept primitive data types - Correct: ✔✔False
    5. T/F: ArrayList implements the List interface - Correct: ✔✔True
    6. T/F: Array List objects handle insertion at the front and rear of a list with equal efficiency - Correct: ✔✔False
    7. T/F: In general, the get() method is more efficient than the next() method - Correct: ✔✔False
    1. T/F: Within a PriorityQueue, the elements sorted last are processed first - Correct: ✔✔False
    2. T/F: You can have a sorted Set that is unordered - Correct: ✔✔False
    3. T/F: Lambda expressions can be used anywhere functional interfaces are expected - Correct: ✔✔True
    4. T/F: When a class implements an interface with default methods and overrides them, the class inherits the default methods' implementations. An interface's designer can now evolve an interface by adding new default and static methods without breaking existing code that implements the interface - Correct: ✔✔False
    5. T/F: Default methods of an interface can be overridden when implementing the interface - Correct: ✔✔True
    6. What are we referring to when we mention java.util.Collections: a. The interface from which lists, queues and sets extend b. The Collections framework c. A utility class for use with collections d. We never mention this - Correct: ✔✔c. A utility class for use with collections
    1. What type of collection would we use if we wanted no duplicates? a. List b. Map c. Queue d. Set - Correct: ✔✔d. Set
    2. What type of collection does not extend the Collection interface? a. List b. Map c. Queue d. Set - Correct: ✔✔b. Map
    3. What type of collection has always been type safe? a. Array b. List c. Map d. Queue e. Set - Correct: ✔✔a. Array
    4. What is the following code snippet an example of:
    5. <? extends Number> a. bounded type b. generic type c. bounded wildcard type

    b. element uniqueness c. priority ordering d. nothing - Correct: ✔✔a. an index

    1. Which List would you use if wanted fast access and were doing lots of insertions and deletions? a. ArrayList b. LinkedList c. Stack d. Vector - Correct: ✔✔b. LinkedList
    2. What type of ordering does a PriorityQueue have? a. ordered and sorted b. ordered and unsorted c. unordered and unsorted - Correct: ✔✔a. ordered and sorted
    3. What type of structure is a Stack? a. FIFO b. LIFO c. PIPO - Correct: ✔✔b. LIFO
    4. What type of map would you use if you wanted it sorted? a. HashMap b. Hashtable c. LinkedHashMap d. TreeMap - Correct: ✔✔d. TreeMap
    1. Which static nested class of Map<K,V> allows us to get a reference to a mapping via an iterator? a. Map.Entry b. Map.Iterator c. Map.Pointer d. Map.Root - Correct: ✔✔a. Map.Entry
    2. Which method do we need to implement in the java.util.Comparator interface? a. compare() b. compareTo() c. sort() d. sortTo() - Correct: ✔✔a. compare()
    3. How many ways does the java.lang.Comparable interface allow us to sort a collection? a. 0 b. 1 c. 2 d. any number - Correct: ✔✔b. 1
    4. What type of Collection implements Lists? A. ordered B. unordered C. sorted - Correct: ✔✔a. ordered

    B. ordered and unsorted C. unordered and unsorted - Correct: ✔✔A. ordered and sorted

    1. What is a hash table? A. A structure that maps values to keys B. A structure that maps keys to values C. A structure used for storage D. A structure used to implement stack and queue - Correct: ✔✔B. A structure that maps keys to values
    2. If several elements are competing for the same bucket in the hash table, what is it called? A. Diffusion B. Replication C. Collision D. Duplication - Correct: ✔✔C. Collision
    3. What do sets care about? A. Index B. Uniqueness C. Speed - Correct: ✔✔B. Uniqueness
    4. What type of set would you use if you wanted a fast access ordered set but didn't care about sorting? A. TreeSet B. HashSet

    C. LinkedHashSet - Correct: ✔✔C. LinkedHashSet

    1. What type of set would you use if you wanted fast access and didn't care about ordering? A. HashSet B. LinkedHashSet C. TreeSet - Correct: ✔✔A. HashSet
    2. What type of exception is raised when we run a program with objects that are not mutually comparable in a sorted set? A. None B. OutOfBoundsException C. RuntimeException D. ClassCastException - Correct: ✔✔D. ClassCastException
    3. What type of set would you use if you wanted it sorted? A. HashSet B. LinkedHashSet C. TreeSet - Correct: ✔✔C. TreeSet
    4. What is the unique feature of LinkedHashSet A. It is not a valid class B. It maintains the insertion order and guarantees uniqueness C. It provides a way to store key values with uniqueness
    1. What are we referring to when we mention java.util.Collections? A. The interface from which lists, queues and sets extend B. The Collections framework C. A utility class for use with collections D. We never mention this - Correct: ✔✔C. A utility class for use with collections
    2. What is the following code snippet an example of? <?> ; A. bounded type B. generic type C. bounded wildcard type D. unbounded wildcard type - Correct: ✔✔D. unbounded wildcard type
    3. The word super is used to specify the __ bound of a wild card. A. lesser B. greater C. lower D. upper - Correct: ✔✔C. lower
    1. Which method do we need to implement in the java.util.Comparator interface? A. compare() B. compareTo() C. sort() D. sortTo() - Correct: ✔✔A. compare()
    2. What is the name of the class that is the ancestor to every other class in Java? A. Java B. Class C. Root D. Object - Correct: ✔✔D. Object
    3. What variable type is returned from both the compare() and compareTo() methods? A. boolean B. char C. int D. String - Correct: ✔✔C. int
    4. An element in a List can be accessed using its : A. size B. length C. capacity D. index - Correct: ✔✔D. index