Questions tagged [implements]

`implements` is a keyword in several programming languages used to denote implementation of an interface.

implements is a keyword in several programming languages which support OOP (such as Java or PHP) used to denote interface implementation (as opposed to extends used to denote implementation inheritance).

Related

404 questions
1
vote
1 answer

Double dispatch using visitor pattern in Java

I have this architecture: In XMLFormulaFormatter, I need the value of instances of Constant (instances which are created in my Main class). I have this method in the Constant class: public double asValue() { return value ; } I have tried this code…
1
vote
0 answers

Delegation causes Access Violation when a type alias is declared?

I'm using Delphi 10.3 Community Edition, targeting Windows 32-bit. I'm writing an interface type. Its class internally uses a TList (and some other objects). In order to avoid having to write several pass-through one-liner methods, I'm using the…
1
vote
3 answers

Java - Adding methods to interface implementation

I'll use an easy example for the sake of the question. If I have an Interface say Animal which is like public interface Animal { void jump(); } And I'm creating an object of the interface on the go, like public class Main { public static…
Srujan Barai
  • 2,295
  • 4
  • 29
  • 52
1
vote
0 answers

Trying to get inputs and implement methods from another class

I'm working on a school project and am pretty hung up. I'm trying to implement methods from the shape2d class (circle, specifically) to get a user input "radius" for a circle to out put the area of circle. If I could figure out ONE SHAPE, I could…
1
vote
2 answers

A class with no modifier (default) cannot access a subclass declared as public? Java

I was just doing practice on Hackerrank since I'm still pretty new to Java (I'm only experienced with C and C++, with minimal Python/Matlab/C#). Basically we only had to write the "Checker class" below from scratch. However, I noticed that when I…
Xavien
  • 13
  • 3
1
vote
1 answer

The method onKeyPreIme(int, KeyEvent) of type myClass must override or implement a supertype

I am trying to create a lock screen in an app so that when the user requests it (remotely) the phone will lock itself with a preset password. I'm trying to use the onKeyPreIme method because I read that onKeyDown() and other related methods…
Jakar
  • 11
  • 1
  • 3
1
vote
0 answers

Implementing interface in different Subclasses with different entities using Java Generic T extends

I am trying to achieve something in Java using Generics, not sure if this is possible or not. If yes, please let me know the correct way. This is the UML Diagram I have. User is the base entity and Customer and Employee are both its subclass (or…
Rito
  • 3,092
  • 2
  • 27
  • 40
1
vote
1 answer

What is the benefit of interfaces when you still need to define each method body separately in each class that implements it?

I'm trying to wrap my head around interfaces and I've been reading a lot of similar questions/answers on the topic, but it's still not clicking with me. I understand what an interface literally is, but I don't get why you would ever use it. So an…
1
vote
1 answer

vba compiling error: not correct implements interface

I am learning vba class. just while i want to compile below simple code, it always shows a error message saying not correct implements interface. i am stucking at this point, someone can help on this? i tried office 2K10 64bit and 2k16 32bit and…
1
vote
1 answer

When I create an object from a class that extends a specific interface, can I use this object in the place where I use this interface?

I know that I can pass an interface as an argument. Since we cannot create an object from an interface! Can I create an object from a class that extends this interface then I use this object in the place where I use this interface as an argument? My…
Allo0o2a
  • 35
  • 1
  • 7
1
vote
1 answer

Can a TypeScript interface constrain its implementing class's properties?

I'd like to define a class, which can have any string property key, but with a specific corresponding value type. I tried the following: interface MyValue { body: string; description: string; } interface MyInterface { [key: string]:…
Harry Solovay
  • 483
  • 3
  • 14
1
vote
2 answers

How to create a new object based on interface implementation

Firstly, I believe my question is badly worded but don't really understand how to phrase it. I have a starting interface that is being implemented by a number of classes. What I want to do is to see if there is a way to create a new object such that…
Mario
  • 339
  • 4
  • 17
1
vote
3 answers

How to ged rid of override all class when add new method in interface

I have interface, abstract method, and more classed and using these reference type as under. public interface InterfaceA { boolean mehod1(); boolean method2(); boolean newMethod(); //When added new method } public abstract…
yasin
  • 49
  • 1
  • 9
1
vote
6 answers

Implement an interface and override methods in Java?

Why do you have to override all methods of an interface? For instance if I have public class Foo extend JFrame implements ActionListener, KeyListener { foo(){ } @Override public void keyPressed(KeyEvent arg) { } …
AlanFoster
  • 8,156
  • 5
  • 35
  • 52
1
vote
0 answers

Typescript intellisense: suggest common export names/types for files in a directory

I don't think this is possible, but is there any way for intellisense to suggest certain properties to be exported from each typescript file in a directory, or matching a filename glob? For example, I have a directory of route handlers. I'd like…
David Budiac
  • 811
  • 2
  • 9
  • 21