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
2
votes
0 answers

Implements, Extends or import a Constants Interface

I am currently working on a legacy code in Java 1.6 and i found that they have a Constants Interface in the Utils package (Is a quite old Webapps) Well, some of the classes import the interface and some just implements it. While i am unable to make…
Grismak
  • 192
  • 16
2
votes
2 answers

C# Param as interface, how to use?

I have a class, which implements this simple interface: public interface IPosition { int? Position { get; set; } } And I have a class to resort collection of classes by this Position property: public static class ReorderPositions { public…
Oleg Sh
  • 8,496
  • 17
  • 89
  • 159
2
votes
3 answers

public interface ITMark>

now i want to implement this interface with the class. so how should i do it? public class TMark implements ITMark{} is this the way but throwing errors I am getting the following: ITMark is a raw type. References to generate type ITMark
karan
  • 21
  • 2
2
votes
0 answers

Typescript: type method params implementing base class

I'm working with TypeScript, and I want to create an interface or type for a MyClass class. I want to be able to type the input parameters of the methods of MyClass, so I implement a BaseClass, which uses some types for input and output values. The…
Emille C.
  • 562
  • 1
  • 7
  • 23
2
votes
1 answer

Is there any way to make each class that implements interface Ae has a List of one of the concrete classes that implement Ba as property?

I have an interface (Ae) that has a list of objects (List) from another interface (Ba). I have a class that implements interface Ae. I have several classes that implement the Ba interface. Is there any way to make each class that implements…
2
votes
4 answers

Difference between "implements" and "All Implemented Interfaces" in Java API

the Java-API tells me which Interfaces a specific class implements. But there are two different kinds of information and I'm not quite sure what that means. For example for the class "TreeSet" :…
Mika2019
  • 47
  • 9
2
votes
1 answer

In Python, what are the pros and cons of implementing an abstract method using a static method?

In Python, what are the pros and cons of implementing an abstract method using a static method? For example, import numpy as np class ExponentialFamily: @abstractmethod def log_normalizer(self, q): raise…
Neil G
  • 32,138
  • 39
  • 156
  • 257
2
votes
1 answer

How to fix an error about PHPDoc on interface class

I'm working on a PHP library and I have two classes. First one is like this: /** * @method static A getInstance() */ interface A {...} Second one is like this: class B implements A {...} getInstance is not defined in A, except in PHPDoc above…
Moradnejad
  • 3,466
  • 2
  • 30
  • 52
2
votes
3 answers

Should I test inheritance and implementation?

Are unit tests supposed to check if a class implements an interface using reflection (same question with inheritance)? If no, why? If the implementation is removed, the code may still compile, and the tests might still be successful (it depends on…
Happy
  • 1,815
  • 2
  • 18
  • 33
2
votes
1 answer

Why were default methods included interfaces in Java 8 instead of adding additional interfaces to the Collection Framework?

Normally, an interface would be frozen once released into production. Hence, if you need added functionality, your option in Java would be to extend an existing interface into a new interface, which describes the added functionality. This ensures…
2
votes
2 answers

Find the training and test error in my self implemented kNN-algorithm

I have implemented my own kNN-algorithm with the iris dataset in python. Now I would like to be able to report the training and test error for different kinds of k. I have calcultated the accuracy of my predictions, but don't really know how to get…
user10411263
  • 49
  • 3
  • 10
2
votes
2 answers

typescript interface: how to implements the interface which merge function interface and property interface

typescript interface: how to implements the interface which merge function interface and property interface. eg: interface keyMap { name: string; mark: number; } let keyMapInstance: keyMap = { name: 'John', mark: 85 } interface development…
JohnPion
  • 45
  • 1
2
votes
2 answers

Force a dynamically loaded class to extend or implement an interface

Anyone know if it's possible in PHP to force a class to extend or implement an interface without the child class having to declare it? Example: interface Requirements { public function __construct(); public function kittens(); } class…
Jay
  • 195
  • 2
  • 10
2
votes
2 answers

Elegant way to implement abstract class

I have an abstract class with a single abstract method; and a number of implementing classes (about 6). The method returns an object that "needs" two parameters. However, in some cases, only one of the two parameters is required. Is there an…
userit1985
  • 961
  • 1
  • 13
  • 28
2
votes
2 answers

java how can I overcome multiple inheritance and diamond problam

I'm trying to understand how can I overcome the "diamond problem" in JAVA let's say I have these 3 interfaces: interface Alpha{ public default int methodA() { int result=0; System.out.println("Print from Alpha methodA"); …
Liana
  • 15
  • 1
  • 8