Q. What will the following code snippet work? If not, what will be the error?

Code:
function test(p) 
{ 
    for (; p.next; p = p.next) ;
    return p;
}
  • (A) No, this will not iterate
  • (B) No, this will result in a runtime error with the message “Cannot use Linked List”
  • (C) No, this will throw an exception as only numerics can be used in a for loop
  • (D) Yes, this will work
πŸ’¬ Discuss
βœ… Correct Answer: (D) Yes, this will work

You must be Logged in to update hint/solution

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
209
Total Visits
πŸ“½οΈ
4 y ago
Published
πŸŽ–οΈ
Manisha Agrawal
Publisher
πŸ“ˆ
80%
Success Rate