Difference between callback and interface

What is the difference between these two piece of code btn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { } }); is that inner interface of View class, if so we know that interf...
more »

2017-08-15 15:08 (5) Answers

Conflict of method call using Interface in Java

Yesterday, I had an interview and I was given the following scenario: There are 3 classes namely Main.java, MobilePhone.java, DeskPhone.java and one Interface ITelephone.java. powerOn() method is implemented in both classes MobilePhone.java and Desk...
more »

2017-08-08 21:08 (3) Answers

Typescript - Generics? Or something else?

I have a problem which produces these errors on the console. Type 'WebFieldB' does not satisfy the constraint 'WebFieldA & WebFieldB'. There are 2 classes generated by server, which shouldn't be changed. class WebFieldA { readonly Name: str...
more »

2017-08-07 18:08 (2) Answers

Design hierarchy with minimal code written

I was once asked to design class/interface hierarchy to implement classes with minimal code redundancy Let's say with have 3 classes that each 2 of them share the same code for some method (that is both class A and B has methodAB(), both class B and...
more »

2017-08-01 11:08 (2) Answers

PHP OOP Interface Code

I am trying to do interface. I have create an interface and then I take two classes. Outside of those classes I am trying to declare a function which will access the common method that is in two classes with the help of interface. I am unable to acce...
more »

2017-07-26 16:07 (0) Answers

Inject an Interface with Angular 4

I'm trying to create a generic DeleteableConfirmationComponent that will allow me to show a confirmation dialog and invoke the delete method from any injected service implementing a Deleteable infterface. To do so, I've created this Interface: expo...
more »

2017-07-15 13:07 (1) Answers

Implementing generic interface in generic class

I'm new to generic types, and was wondering how could I correctly implement the generic interface in a generic class, so the determination of type would be delayed to moment when I'm instantiating an object of this generic class. My code looks as f...
more »

2017-07-15 11:07 (1) Answers

Generic Binary Tree Java

my Task ist to write a generic binary tree in java with classes Node and Tree and NodeActionInterface public interface NodeActionInterface { public void action(); } This is my Node: public class Node <T> implements NodeActionInterface { &l...
more »

2017-07-14 09:07 (2) Answers

Generic interface of an interface

Foreword: Title may not state the real problem I am having. I just donĀ“t know I could express my problem in a better and short way. I have a question regarding generic interface implementation in C# regarding the following structure: public interf...
more »

2017-07-06 12:07 (0) Answers

Name clash from implementing interface

I have spent a few hours reading Java documentation/Stackoverflow answers on generics and type erasure but I still don't understand the topic fully. The problem is implementing the following simple interface: public interface Stack { void push(Obje...
more »

2017-07-05 07:07 (3) Answers

Overlapping java-like interfaces in C++

I've read on many places that Java's interface can be 100% emulated using C++'s abstract class with all pure virtual methods. I'm trying to convert this piece of java code: interface A { void a(); } interface B extends A { void b(); } cla...
more »

2017-07-04 09:07 (2) Answers

How is this valid generic method in java?

class GenMethDemo { // Determine if an object is in an array. static <T extends Comparable<T>, V extends T> boolean isIn(T x, V[] y) { for(int i=0; i < y.length; i++) if(x.equals(y[i])) return true; } } how can Comp...
more »

2017-07-02 13:07 (2) Answers