473,378 Members | 1,106 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

overriding method in interface

oll3i
679 512MB
Expand|Select|Wrap|Line Numbers
  1. public interface IQResStack {
  2.         void push(IAbstractQueryResult a);
  3.  
  4. }
  5.  
  6. public class QResStack implements IQResStack{
  7.  
  8.  public void push(AbstractQueryResult a){
  9.  }
  10.  
it says it does not overide the method in interface?
Oct 26 '13 #1
5 1744
Nepomuk
3,112 Expert 2GB
Well, it doesn't. The interface defines a function that overrides a function that takes an IAbstractQueryResult which, judging by the name, is an interface. The class however has a function taking an AbstractQueryResult which is a class. That won't work.

Also when overriding a method it is good practice to use the @Overrides annotation; that way the IDE you're using will tell you when something goes wrong with overriding.

So, the end result would look like this:
Expand|Select|Wrap|Line Numbers
  1. public class QResStack implements IQResStack {
  2.  
  3.     @Override
  4.     public void push(IAbstractQueryResult a) {
  5.     }
  6. }
Oct 26 '13 #2
oll3i
679 512MB
what about pop()
it says that it does not override the method in the supertype
Oct 26 '13 #3
Nepomuk
3,112 Expert 2GB
I see no pop() function in your code. However if you're getting that error I guess you've added the @Override annotation to it? You can only do that legally if your function is actually overriding a function from a supertype, i.e. parent class or implemented interface. And there are some limits; the signatures of the functions have to match and you can't override private or final functions and you can't override anything but methods.
Oct 26 '13 #4
oll3i
679 512MB
so it's like that? that works

Expand|Select|Wrap|Line Numbers
  1. @Override
  2. public IAbstractQueryResult pop () {
  3. return aR;
  4.   }
  5. @Override
  6. public void push(IAbstractQueryResult a) { 
  7.     }
Oct 26 '13 #5
Nepomuk
3,112 Expert 2GB
I'm guessing your interface looks like this:
Expand|Select|Wrap|Line Numbers
  1. public interface IQResStack {
  2.  
  3.         IAbstractQueryResult pop();
  4.  
  5.         void push(IAbstractQueryResult a);
  6. }
correct? If so then yes, your use of the @Override annotation should be valid.
Oct 26 '13 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Allan Streib | last post by:
Here is what I need to do: The bsddb3 module (http://pybsddb.sourceforge.net/) defines a class called _DBWithCursor which has a method called set_location. The code for set_location looks like:...
10
by: Stuart McGraw | last post by:
I have a class A from a third party that I cannot change and is implemented in C. I derive my own class B from A and add a couple new methods and override a method. The problem is that A has a...
3
by: Amit chaturvedi | last post by:
Dear Friends Please tell me following thing Que -: what is the main use of interface in .net Que -: What is difference between abstract class and interface Que -: How to make class in Object...
1
by: VMI | last post by:
I want to override this method: private void dataGrid_browse_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { ... } How can I do this?
1
by: Joel | last post by:
Why does this work: using System; namespace ConsoleApplication1 { class Class1 { static void Main(string args)
6
by: Mike | last post by:
Hi, I have such problem: On my form I have TabControl. I want to move from one tab to another using "Next" and "Prev" button. This part works fine. But control also supports switching between...
1
by: john_teague | last post by:
I'm working with a code generator that uses partial classes to generated the basic stuff and leave the other file alone for you to make changes. In the 1.1 version we would inherit from a class...
2
by: Michael Moreno | last post by:
Hello, In a Base Form I have a toolbar and have implemented the Click event as: protected virtual void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)...
52
by: Ben Voigt [C++ MVP] | last post by:
I get C:\Programming\LTM\devtools\UselessJunkForDissassembly\Class1.cs(360,27): error CS0535: 'UselessJunkForDissassembly.InvocableInternals' does not implement interface member...
6
GaryTexmo
by: GaryTexmo | last post by:
Hey all, You'll have to forgive me here, I'm a C# developer so my PHP lingo might not be quite right. I'll try to explain the problem as best I can and hopefully you guys get the idea. I want...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.