Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
11th Edition
ISBN: 9780134670942
Author: Y. Daniel Liang
Publisher: PEARSON
bartleby

Concept explainers

Expert Solution & Answer
Book Icon
Chapter 24, Problem 24.5PE

Explanation of Solution

Implementation of GenericQueue using inheritance:

//Define a class Ex24_05

public class Ex24_05 {

//Define the main() function

public static void main(String[] args) {

//Create the generic queue

GenericQueue<String> queue = new

GenericQueue<String>();

//Add the elements into queue

queue.enqueue("Tom");

queue.enqueue("George");

queue.enqueue("Peter");

}

}

//Implement the queue using inheritance

class GenericQueue<E> extends java.util.LinkedList<E> {

//Define the method enqueue()

public void enqueue(E o) {

//Add the elements at the last

this...

Blurred answer
Students have asked these similar questions
(Please Help. My professor did not teach us any of this and will not answer my emails) Design a class named Queue for storing integers. Like a stack, a queue holds elements. In a stack, the elements are retreived in a last-in-first-out fashion. In a queue, the elements are retrieved in a first-in-first-out fashion. The class contains: An int[] data field named elements that stores the int values in the queue A data field named size that stores the number of elements in the queue A constructor that creates a Queue object with defult capacity 8 The method enqueue(int v) that adds v into the queue The method empty () that returns true if the queue is empty The method getSize() that returns the size of the queue
Fill in the blanks in each of the following statements (CHOOSE ONLY TEN): 5 AP 1. An --- is created to store information of the method such as the parameters and (0- local variables specific to a given call of the method, and information about which command in the body of the method is currently executing. 21. One application of stack is 32. The type of linked list which is contain more memory space is 3. The --------- operation return the top item of stack. 54. The method used to removes beginning and ending spaces of string 6 5. stack is said underflow when 6. String objects are stored in a special memory area known as 7. Two dimensional array that have a different length is called ----------- A 8. One way to create string object is -------- 10 9. is known as expression. 110. Example of none linear data structures is 12 11. A is a method that contains a statement that makes a call to itself. 13 12. One application of queue is
JAVA CODE Learning Objectives: Detailed understanding of the linked list and its implementation. Practice with inorder sorting. Practice with use of Java exceptions. Practice use of generics.   You have been provided with java code for SomeList<T> class.  This code is for a general linked list implementation where the elements are not ordered.  For this assignment you will modify the code provided to create a SortedList<T> class that will maintain elements in a linked list in ascending order and allow the removal of objects from both the front and back.  You will be required to add methods for inserting an object in order (InsertInorder) and removing an object from the front or back.  You will write a test program, ListTest, that inserts 25 random integers, between 0 and 100, into the linked list resulting in an in-order list.  Your code to remove an object must include the exception NoSuchElementException.  Demonstrate your code by displaying the ordered linked list and…
Knowledge Booster
Background pattern image
Computer Science
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.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education