Linked List Test Part 2
By Mickey Arnold
starstarstarstarstar
Last updated 10 months ago
3 Questions
Part 1 : Show the output of each block of code below. ( 50 points ) If a syntax or run-time error would occur, write error.
1. What is the output of code below?
ListNode x = new ListNode("8",new ListNode("2",new ListNode("6",null)));
out.println(x.getValue());
out.println(x.getNext().getNext().getValue());
out.println(x.getNext().getValue());
out.println(x.getNext().getNext().getNext());
2.What is the output of code below?
ListNode z = new ListNode("slide",new ListNode("speed", new ListNode("slow",new ListNode("dance", new ListNode("skip",null)))));
while(z!=null)
{
out.println(z.getValue());
z=z.getNext();
}