A method int size( ) in a linked list class returns the number of elements stored in the list by executing the single statement return count;For this to work correctly,
A) count must be a static variable in the class,initialized to 0,incremented by each add method,and decremented by each remove method
B) count must be an instance variable in the class,initialized to 0,incremented by each add method,and decremented by each remove method
C) count must be a local variable in each add and remove method: the add methods must increment count,and the remove methods must decrement count.
D) It is not possible for size to just return the count value: the size method must set count to 0 and then increment count once for each element in the list.
Correct Answer:
Verified
Q1: The objects that form the units of
Q2: To remove a node X with index
Q3: In a linked list implementation using a
Q5: A list in which each stored element
Q6: A Node class for a linked list
Q7: In Java,the first node in a list
Q8: To remove a node with index 0
Q9: A systematic procedure for starting at the
Q10: In a linked list,the successor of a
Q11: A list method void add(int index,E x)seeking
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents