Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7611707
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:43:45+00:00 2026-05-31T01:43:45+00:00

I am trying to implement the Java 1.6 Queue interface, but I am getting

  • 0

I am trying to implement the Java 1.6 Queue interface, but I am getting the error:

MyBoundedQueue.java:27: MyBoundedQueue is not abstract and does not override abstract method offer(java.lang.Object) in java.util.Queue

What I really don’t understand is that there is no offer(Object) method in the Queue class. The Java 1.6 API for Queue says there is a method boolean offer(E e), where E is a parameterized type, and indeed, I have implemented that, as shown below.

Any help?

import java.util.ArrayDeque;
import java.util.Iterator;
import java.util.Queue;

public class MyBoundedQueue<ItemType> implements Queue
{
    private int _maxSize;
    private ArrayDeque<ItemType> _window;

    public MyBoundedQueue(int maxSize)
    {
        _maxSize = maxSize;
        _window = new ArrayDeque<ItemType>(_maxSize);
    }

    public boolean add(ItemType item)
    {
        if (_window.size() >=  _maxSize)
        {
            _window.removeFirst();
        }

        _window.addLast(item);
    }

    public ItemType element()
    {
        return _window.element();
    }

    public boolean offer(ItemType item)
    {
        add(item);
        return true;
    }

    public ItemType peek()
    {
        return _window.peek();
    }

    public ItemType poll()
    {
        return _window.poll();
    }

    public ItemType remove()
    {
        return _window.remove();
    }

    public void clear()
    {
        _window.clear();
    }

    public int size()
    {
        return _window.size();
    }

    public Iterator<ItemType> iterator()
    {
        return _window.iterator();
    }


}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T01:43:47+00:00Added an answer on May 31, 2026 at 1:43 am

    You need to change it to:

    public class MyBoundedQueue implements Queue<ItemType>
    

    It’s telling you offer(Object) because without the Generic typing that’s what it would be. You also don’t need to specify a generic type for your class … you’re not using generic types anywhere.

    If you wanted your class to use generics you’d want to do:

    public class MyBoundedQueue<T> implements Queue<T> {
    ...
    

    And everywhere you currently have ItemType you’d use T instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to implement QuickSort algorithm program in Java, but I'm getting incorrect answer.
I am trying to implement a Stack in java (using the list interface: Interface
I'm trying to implement RSA Encryption in both Java and PHP, but I can't
I'm trying to implement an interface, but I get the 'Null-pointer' exception, but I
I am trying to implement a Queue in C. Coming from Java and other
I am trying to implement a Linked List Sequence in Java however my method
I'm trying to implement the following operation in Java and am not sure how:
I am trying to implement generics in Java using Comparable<T> interface. public static <T>
I am trying to implement a huge Java interface with numerous (~50) getter and
I am trying to implement an efficient priority queue in Java. I got to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.