Question

Suppose we define a class called "Something" that maintains a list of objects of some type....

Suppose we define a class called "Something" that maintains a list of objects of some type. Suppose further that we declare methods "doA" and "doB" in the class. Method "doA" has a void return type and takes an object received as an input argument and adds it to the end of the list. Method "doB" removes the object that is in the first position in the list and returns it. What type of abstract data structure does the class represent?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

The data structure used is queue.

In a queue data structure, the data structure is of type FIFO Or First In First Out. So, the element which is added the first in the queue is the one to be removed first and the element added the last is removed last.

So, as the new element is added in the end of the list, then the element in the front is the element which is added first in the list and is removed first.

Add a comment
Know the answer?
Add Answer to:
Suppose we define a class called "Something" that maintains a list of objects of some type....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Create a class Circle with one instance variable of type double called radius. Then define an...

    Create a class Circle with one instance variable of type double called radius. Then define an appropriate constructor that takes an initial value for the radius, get and set methods for the radius, and methods getArea and getPerimeter. Create a class RightTriangle with three instance variables of type double called base, height, and hypotenuse. Then define an appropriate constructor that takes initial values for the base and height and calculates the hypotenuse, a single set method which takes new values...

  • Define a class DoubleStack which implements two stacks of objects of type Object using a single...

    Define a class DoubleStack which implements two stacks of objects of type Object using a single shared array, so that the push and pop operations specify which of the two stacks is involved in the operation (as described below). (a) Specify necessary instance variables and write a constructor “DoubleStack(int n)” that takes integer n and creates an empty DoubleStack object with the shared array with room for n elements (2 pt); b) Write methods "boolean push(int i, Object o)" and...

  • Your text has an example of LinkedList class. Convert the class so that the Link objects have a s...

    Your text has an example of LinkedList class. Convert the class so that the Link objects have a single long instance variable -- call it "data" -- and the Link instance variable.. Step 2 Then add the following capabilities to the class. A constructor that takes an array of longs as an argument. The contents of the array are use to create Link objects that become objects in the LinkedList. A "search" method that takes a long argument and returns...

  • Java HW Define a class called Counter whose objects count things. An object of this class...

    Java HW Define a class called Counter whose objects count things. An object of this class records a count that is a nonnegative integer. Include methods to set the counter to 0, to increase the count by 1, and to decrease the count by 1. Be sure that no method allows the value of the counter to become negative. Include an accessor method that returns the current count value and a method that outputs the count to the screen. There...

  • implement a class called PiggyBank that will be used to represent a collection of coins. Functionality...

    implement a class called PiggyBank that will be used to represent a collection of coins. Functionality will be added to the class so that coins can be added to the bank and output operations can be performed. A driver program is provided to test the methods. class PiggyBank The PiggyBank class definition and symbolic constants should be placed at the top of the driver program source code file while the method implementation should be done after the closing curly brace...

  • Define a C++ class managing objects using a Linked List. (10 points) Define a C++ class...

    Define a C++ class managing objects using a Linked List. (10 points) Define a C++ class named "BirthdayList" that manages a list of Birthday objects as a linked list maintaining the order of entry (first birthday should be displayed first). Write a main function to show that you can add a list of birthdays and print out that list in the order that you have entered. (5 points) Add a "search" method into the "BirthdayList" class that accepts a Birthday...

  • Create an abstract class “Appointment” that represents an event on a calendar. The “Appointment” class will...

    Create an abstract class “Appointment” that represents an event on a calendar. The “Appointment” class will have four instance variables: • An instance variable called “year” which will be of type int • An instance variable called “month” which will be of type int • An instance variable called “day” which will be of type int • An instance variable called “description” which will be of type String The “Appointment” class must also implement the following methods: • A getter...

  • Need help to create general class Classes Data Element - Ticket Create an abstract class called...

    Need help to create general class Classes Data Element - Ticket Create an abstract class called Ticket with: two abstract methods called calculateTicketPrice which returns a double and getld0 which returns an int instance variables (one of them is an object of the enumerated type Format) which are common to all the subclasses of Ticket toString method, getters and setters and at least 2 constructors, one of the constructors must be the default (no-arg) constructor. . Data Element - subclasses...

  • In Java* Please implement a class called "MyPet". It is designed as shown in the following...

    In Java* Please implement a class called "MyPet". It is designed as shown in the following class diagram. Four private instance variables: name (of the type String), color (of the type String), gender (of the type char) and weight(of the type double). Three overloaded constructors: a default constructor with no argument a constructor which takes a string argument for name, and a constructor with take two strings, a char and a double for name, color, gender and weight respectively. public...

  • Assignment Description. In this assignment, you will design a class to represent a book of recipes...

    Assignment Description. In this assignment, you will design a class to represent a book of recipes using a doubly linked list. Your recipe book will support methods to add a recipe and get a recipe at a position; your main will use these to print all the names of all the recipes in the book. Create a C++ class called RecipeBook. Your class must implement the following variables, constructors, and methods: Create a private inner class called Node for implementing...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT