public interface Queue Interface { } public void enqueue (T object) throws Exception; public T dequeue () throws Exception; public int size(); public String toString();
public interface Queue Interface { } public void enqueue (T object) throws Exception; public T dequeue () throws Exception; public int size(); public String toString();
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
* QueueArrayList.java This file implements QueueInterface.java This file has
* only one ArrayList<T> type of attribute to hold queue elements. One default
* constructor initializes the ArrayList<T> queue. An enqueue method receives an
* object and place the object into the queue. The enqueue method does not throw
* overflow exception. A dequeue method returns and removes an object from queue
* front. The dequeue method will throw exception with message "Underflow" when
* the queue is empty. A size method returns number of elements in the queue. A
* toString method returns a String showing size and all elements in the queue.
Please help me in java

Transcribed Image Text:public interface Queue Interface<T> {
}
public void enqueue(T object) throws Exception;
public T dequeue () throws Exception;
public int size();
public String toString();
![public class QueueDemo {
}
public static void main(String[] args) {
testQueue (new QueueArray<String>(3));
testQueue (new QueueArrayList<String>());
testQueue (new QueueLinkedList<String>());
}
private static void testQueue (Queue Interface<String> q) {
try {
}
q. enqueue ("We're");
q. enqueue ("the");
q.enqueue ("champions.");
System.out.print(q.dequeue()
q.enqueue ("Summer");
System.out.print(q.dequeue()
System.out.println(q.dequeue ());
q. enqueue ("fun.");
System.out.println("\n" + q);
q.dequeue ();
q. dequeue ();
q.dequeue ();
} catch (Exception e) {
}
+ ');
1
+ ');
System.out.println(e.getMessage());
System.out.println(".
.");](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fef46eeed-5fd5-425f-8ad9-d5c078a8040a%2Fbf304844-3fab-4bc7-a421-adaf4d2db6a3%2Fjbwpvjo_processed.png&w=3840&q=75)
Transcribed Image Text:public class QueueDemo {
}
public static void main(String[] args) {
testQueue (new QueueArray<String>(3));
testQueue (new QueueArrayList<String>());
testQueue (new QueueLinkedList<String>());
}
private static void testQueue (Queue Interface<String> q) {
try {
}
q. enqueue ("We're");
q. enqueue ("the");
q.enqueue ("champions.");
System.out.print(q.dequeue()
q.enqueue ("Summer");
System.out.print(q.dequeue()
System.out.println(q.dequeue ());
q. enqueue ("fun.");
System.out.println("\n" + q);
q.dequeue ();
q. dequeue ();
q.dequeue ();
} catch (Exception e) {
}
+ ');
1
+ ');
System.out.println(e.getMessage());
System.out.println(".
.");
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 4 steps with 3 images

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON

Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education