Questions tagged [concreteclass]

34 questions
50
votes
13 answers

internal member in an interface

I have a list of objects implementing an interface, and a list of that interface: public interface IAM { int ID { get; set; } void Save(); } public class concreteIAM : IAM { public int ID { get; set; } internal void Save(){ …
fer
17
votes
3 answers

How to call constructor with interface arguments when mocking a concrete class with Moq

I have the following class, which uses constructor injection: public class Service : IService { public Service(IRepository repository, IProvider provider) { ... } } For most methods in this class, I simply create Moq mocks for IRepository and…
Nick Williams
  • 2,864
  • 5
  • 29
  • 43
15
votes
4 answers

Should the return type of a method declaration be interface or concrete class?

In general scenario, the interface or abstract class is often the appropriate decision, am I right? But in some cases, it looks like the concrete class is better. For instance, public string Replace(string old, string new) The Replace method of…
Kirin Yao
  • 1,606
  • 2
  • 14
  • 21
13
votes
2 answers

Data Binding Error Trying to Pass ViewModel into Include Layout with Abstract Variable Type

*EDIT: To answer my own question, I had to add EditorViewModel as an import to the parent abstract class in the outer layout, and cast the viewModel to the parent class using app:viewModel="@{((EditorViewModel)viewModel)}", that was it! I swear I…
5
votes
1 answer

Difference between Concrete class and Abstract class in Objective-C

I'm learning iOS development right now and I came across concrete and abstract class. What are the difference between these class. I've searched online but they're in other languages not in Objective-C.
user3526002
  • 537
  • 2
  • 8
  • 19
4
votes
4 answers

Returning interface but concrete may have properties not on the interface, can I get them with a cast?

I have a feeling that my use of an interface is incorrect. I know that an interface is a contract that the concrete class has to adhere to. So I will explain the problem I am trying to solve and maybe someone can point me in the right direction. I…
David McLean
  • 1,462
  • 1
  • 12
  • 27
3
votes
3 answers

Access "this" pointer of concrete class from interface

After writing a test, I determined that the this pointer in an interface is not equal to the this pointer of the concrete class, meaning I can't just use a C-style cast on it. class AbstractBase {...}; class AnInterface { public: AnInterface()…
user4670511
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
2 answers

Can "override abstract methods" be substituted with "implement abstract methods" in Java inheritance?

In Java inheritance, can the expression "overriding an abstract method" be used interchangeably with the expression "implementing an abstract method"? I came across the following question in the book "OCA Java SE 8 Programmer I Study Guide" in…
2
votes
3 answers

Mocking return values of a concrete class method using Moq

I have an abstract factory like this. public abstract class AbstractFactory { public abstract ISyncService GetSyncService(EntityType entityType); } And I have its concrete implementation like this. public class SyncFactory : AbstractFactory { …
Prasadi
  • 97
  • 7
1
vote
3 answers

Java interface that returns objects with its own type

I was looking at an interface that is built into Java, and noticed that it has methods which return objects of its own type. Specifically, the IntStream interface has a method range which returns an IntStream object (i.e. some object that implements…
alex
  • 61
  • 5
1
vote
1 answer

Abstract Class and Concrete Subclasses

I have two files: Validador.java and Peca.java. This is what I have in my Validador: public class Validador { public static void main(String[] args) { if(args.length == 0) { Peca p = new Rainha("t",1,2); }else if…
1
vote
1 answer

How to Subclassing with Concrete Parameters

I have a class Transaction and a Service interface public class Transaction {} public interface RequestService { public String getRequest(Transaction transaction); } Now I want to subclass the Transaction class and have a concrete class for…
bcr666
  • 2,157
  • 1
  • 12
  • 23
1
vote
1 answer

Is my empty "public class xList extends ArrayList" concrete?

I'm struggling to understand what is a concrete class. Currently I have an empty class as so: public class xList extends ArrayList { } In a different class and using main method i use: xList list = new xList(); and then add to it using:…
JMa
  • 76
  • 1
  • 7
1
vote
1 answer

C++ Abstract / Concrete Class Declaration

I have a MotorDefinition class and an abstract class called Motor: class MotorDefinition { public: MotorDefinition(int p1, int p2, int p3) : pin1(p1), pin2(p2), pin3(p3) {} int pin1 = -1; int pin2 = -1; int pin3 = -1; }; class Motor…
Bob Jones
  • 2,049
  • 5
  • 32
  • 60
1
2 3