in Education by
What is difference between dequeue() and peek() function of java? (a) dequeue() and peek() remove and return the next time in line (b) dequeue() and peek() return the next item in line (c) dequeue() removes and returns the next item in line while peek() returns the next item in line (d) peek() removes and returns the next item in line while dequeue() returns the next item in line This question was posed to me in an internship interview. Enquiry is from Data Structures-Queue in section java.util – The Collections Framework of Java Select the correct answer from above options

1 Answer

0 votes
by
 
Best answer
Correct answer is (c) dequeue() removes and returns the next item in line while peek() returns the next item in line Easiest explanation: dequeue() removes the item next in line. peek() returns the item without removing it from the queue.

Related questions

0 votes
    What is difference between dequeue() and peek() function of java? (a) dequeue() and peek() remove ... programming questions and answers pdf, java interview questions for beginners...
asked Oct 25, 2021 in Education by JackTerrance
0 votes
    What is the difference between length() and size() of ArrayList? (a) length() and size() return the ... Collections Framework of Java Select the correct answer from above options...
asked Mar 1, 2022 in Education by JackTerrance
0 votes
    What is the difference between TreeSet and SortedSet? (a) TreeSet is more efficient than SortedSet (b) SortedSet ... Framework of Java Select the correct answer from above options...
asked Mar 1, 2022 in Education by JackTerrance
0 votes
    What is the difference between Queue and Stack? (a) Stack is LIFO; Queue is FIFO (b) Queue is LIFO; ... Collections Framework of Java Select the correct answer from above options...
asked Mar 1, 2022 in Education by JackTerrance
0 votes
    Which method is used to generate boolean random values in java? (a) nextBoolean() (b) randomBoolean() (c) ... Utility Classes of Java Select the correct answer from above options...
asked Feb 24, 2022 in Education by JackTerrance
0 votes
    Which of these object stores association between keys and values? (a) Hash table (b) Map (c) Array (d ... Collections Framework of Java Select the correct answer from above options...
asked Mar 1, 2022 in Education by JackTerrance
0 votes
    What are the initial capacity and load factor of HashSet? (a) 10, 1.0 (b) 32, 0.75 (c) 16, 0. ... - The Collections Framework of Java Select the correct answer from above options...
asked Mar 1, 2022 in Education by JackTerrance
0 votes
    Which of these method is used to insert value and its key? (a) put() (b) set() (c) insertElement( ... The Collections Framework of Java Select the correct answer from above options...
asked Mar 1, 2022 in Education by JackTerrance
0 votes
    Which of these is the interface of legacy is implemented by Hashtable and Dictionary classes? (a) Map (b) ... Framework of Java Select the correct answer from above options...
asked Mar 1, 2022 in Education by JackTerrance
0 votes
    What are the use of front and rear pointers in CircularQueue implementation? (a) Front pointer points to first ... Framework of Java Select the correct answer from above options...
asked Mar 1, 2022 in Education by JackTerrance
0 votes
    What is the correct method used to insert and delete items from the queue? (a) push and pop (b) ... Collections Framework of Java Select the correct answer from above options...
asked Mar 1, 2022 in Education by JackTerrance
0 votes
    When two threads access the same ArrayList object what is the outcome of the program? (a) Both are able ... Framework of Java Select the correct answer from above options...
asked Mar 1, 2022 in Education by JackTerrance
0 votes
    How is Arrays.asList() different than the standard way of initialising List? (a) Both are same (b) ... Collections Framework of Java Select the correct answer from above options...
asked Mar 1, 2022 in Education by JackTerrance
0 votes
    Which class provides thread safe implementation of List? (a) ArrayList (b) CopyOnWriteArrayList (c) HashList (d) ... Framework of Java Select the correct answer from above options...
asked Mar 1, 2022 in Education by JackTerrance
0 votes
    Which of the below is not an implementation of List interface? (a) RoleUnresolvedList (b) Stack (c) AttibuteList ... Framework of Java Select the correct answer from above options...
asked Mar 1, 2022 in Education by JackTerrance
...