What is the functionality of the following piece of code? Select the most…
PYQ AMCAT 2023
What is the functionality of the following piece of code? Select the most appropriate.
public void function(int data)
{
int flag = 0;
if( head != null)
{
Node temp = head.getNext();
while((temp != head) && (!(temp.getItem() == data)))
{
temp = temp.getNext();
flag = 1;
break;
}
}
if(flag)
System.out.println("success");
else
System.out.println("fail");
}
- A.
Print success if a particular element is not found
- B.
Print fail if a particular element is not found
- C.
Print success if a particular element is equal to 1
- D.
Print fail if the list is empty
Attempted by 102 students.
Sign up free to check your answer
Sign up freeLoading lesson…

