The code for implementing the String pop() operation is


A stack based on a linked list is based on the following code


```
class Node
{
String element;
Node next;
Node(String el, Node n)
{
element = el;
next = n;
}
}
Node top = null;

```

A)

if (top != null)
{
top = top.next;
String el = top.element;
return el;
}
else throw new RuntimeException("Empty Stack");
B)
if (top != null)
{
String el = top.element;
top = top.next;
return el;
}
else throw new RuntimeException("Empty Stack");
C)
if (top != null)
{
String el = top.element;
top = null;
return el;
}
else throw new RuntimeException("Empty Stack");
D)
return top.element;
top = top.next;


B)
if (top != null)
{
String el = top.element;
top = top.next;
return el;
}
else throw new RuntimeException("Empty Stack");

Computer Science & Information Technology

You might also like to view...

Which component contains menus?

a. Menu button. b. Title bar. c. Menu bar. d. Combo box.

Computer Science & Information Technology

The Calendar view is the default view for the Calendar List in SharePoint

Indicate whether the statement is true or false

Computer Science & Information Technology

What is the most likely problem if a ping fails when using a device's hostname but not when using the device's IP address?

A) ARP B) DNS C) DHCP D) ND

Computer Science & Information Technology

Impact printers are

A) Dot-matrix printers B) Nonimpact printers C) Optical printers D) LED printers

Computer Science & Information Technology