Sail E0 Webinar
Question
Which of the following performs the fetch operation?
Options:
A .  public Object fetch(int index){        List cur = this.next;        Object val = null;        while (cur != null && cur.index != index)        {            cur = cur.next;        }        if (cur != null)        {            val = cur.val;        } else        {            val = null;        }        return val;}
B .  public Object fetch(int index){        List cur = this;        Object val = null;        while (cur != null && cur.index != index)        {            cur = cur.next;        }        if (cur != null)        {            val = cur.val;        } else        {            val = null;        }        return val;}
C .  public Object fetch(int index){        List cur = this;        Object val = null;        while (cur != null && cur.index != index)        {            cur = cur.index;        }        if (cur != null)        {            val = cur.val;        } else        {            val = null;        }        return val;}
D .  None of the mentioned
Answer: Option B


You travers through the array until the end is reached or the index is found and return the element at that index, null otherwise.



Was this answer helpful ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers