Examveda

Select the code snippet which return true if the stack is empty, false otherwise.

A.

public boolean empty()
{
     return q2.isEmpty();
}

B.

public boolean empty() 
{
     return q1.isEmpty() || q2.isEmpty();
}

C.

public boolean empty() 
{
     return q1.isEmpty();
}

D.

public boolean empty() 
{
     return q1.isEmpty() & q2.isEmpty();
}

Answer: Option B


This Question Belongs to Data Structure >> Introduction To Data Structures

Join The Discussion

Related Questions on Introduction to Data Structures