In java language Use the following pseudocode for the next six questions. aList
ID: 3694339 • Letter: I
Question
In java language
Use the following pseudocode for the next six questions. aList is type LinkedList<Integer>
aList.add(4);
aList.add(7);
aList.add(12);
System.out.println(aList.remove( ) ); // r1
aList.add(5);
aList.add(8);
aList.add(18);
System.out.println(aList.get(0)); // r2
System.out.println(aList.remove( )); // r3
aList.add(1, 3);
System.out.println(aList.remove( ));
System.out.println(aList.remove( )); // r4
System.out.println(aList.remove( )); // r5
Question 1
What value is printed in the line of code marked r1?
Answer:
Question 2
What value is printed in the line of code marked r2?
Answer:
Question 3
What value is printed in the line of code marked r3?
Answer:
Question 4
What value is printed in the line of code marked r4?
Answer:
Question 5
What value is printed in the line of code marked r5?
Answer:
Question 6
After the code executes, how many elements would remain in a?
Answer
Part 2
Use the following pseudocode for the next four questions. q is type Queue<Integer>.
q.enqueue(4);
q.enqueue(2);
q.enqueue(7);
System.out.println(q.dequeue( ) ); // d1
q.enqueue(1);
q.enqueue(3);
System.out.println(q.dequeue( )); // d2
System.out.println(q.dequeue( )); // d3
q.enqueue(5);
q.enqueue(8);
Question 1
What value is printed in the line of code marked d1?
Answer:
Question 2
What value is printed in the line of code marked d2?
Answer:
Question 3
What value is printed in the line of code marked d3?
Answer:
Question 4
After the code executes, how many elements would remain in q?
Answer:
Explanation / Answer
Question 1
What value is printed in the line of code marked r1?
Answer:4
Question 2
What value is printed in the line of code marked r2?
Answer:7
Question 3
What value is printed in the line of code marked r3?
Answer:7
Question 4
What value is printed in the line of code marked r4?
Answer:3
Question 5
What value is printed in the line of code marked r5?
Answer:5
Question 6
After the code executes, how many elements would remain in a?
Answer: 2 elements would remaing : 8,18
Part 2
Question 1
What value is printed in the line of code marked d1?
Answer: 4
Question 2
What value is printed in the line of code marked d2?
Answer:2
Question 3
What value is printed in the line of code marked d3?
Answer:7
Question 4
After the code executes, how many elements would remain in q?
Answer: 4 elements would remain. 1,3,5,8
Let me know if you have any queries.
Thanks.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.