Write a Java program that traces the following methods for a linked list queue, starting from an empty queue and performing them in sequence:
import java.lang.*;
class LinkList
{
char ch;
LinkList next;
// constructor to create a new node
public LinkList(char c)
{
this.ch = c;
this.next = null;
}
}
//class queue using link list
class QueueTest
{
LinkList front, rear;
//default constructor
public QueueTest()
{
this.front = this.rear = null;
}
//method to insert a character into queue
void enqueue(char c)
{
// creaet a linklist object
LinkList lobj = new LinkList(c);
// condition for insert a first element
if (this.rear == null) {
this.front = this.rear = lobj;
return;
}
// insert the node at the end of queue
this.rear.next = lobj;
this.rear = lobj;
}
// Function to delete an element from queue
LinkList dequeue()
{
// condition for empty queue
if (this.front == null)
return null;
LinkList lobj = this.front;
this.front = this.front.next;
//link list having single element
if (this.front == null)
this.rear = null;
return lobj;
}
}
public class Test
{
//driver program
public static void main(String[] args)
{
//declare the queue object
QueueTest qobj = new QueueTest();
//inpsert c into queue
qobj.enqueue('c');
//insert d into queue
qobj.enqueue('d');
//perform dequeue() operation
System.out.println("Dequeued item is " + qobj.dequeue().ch);
System.out.println("Dequeued item
is " + qobj.dequeue().ch);
}
}
output

Write a Java program that traces the following methods for a linked list queue, starting from...