8:37 AM tacomacc.instructure.com ..ooo AT&T; Quizzes M 1Y: Doubry Linkea List bu
ID: 3607061 • Letter: 8
Question
8:37 AM tacomacc.instructure.com ..ooo AT&T; Quizzes M 1Y: Doubry Linkea List bug MQ 19: Doubly Linked List Bug Started: Nov 1 at 8:37am entsQuiz Instructions D Question 1 1 pts In class, we saw that the following 28 Conductor hasNext didn't work correctly public boolean hasNext) Calendar return car.next null; ns Instead, we had to put the following: Inbox public boolean hasNext) return car null; cord- What was wrong with the behavior of the old ry It returned false for the first head) element of the list O It returned false for the last (tail) element of the list O It never returned false O It always returned false Not saved Submit Quiz k-Explanation / Answer
Answer :
option B - it returned false for the last element of the list
Reason:
It is because as per the first implementation it always checks for the next element is null or not .
But when the last element is addressed it checks for the next element which is not present and it gets null as value.
now the comparision (null != null) gives false which is returned by hasnext() method and finally code doesn't work for last element.
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.