Re: Can Interfaces be mimicked with classes



sundarvenkata wrote:

I bet this is homework. Oh well, I've already written the reply.

Can the functionality of interfaces be mimicked with classes??

Not in Java, no. The things you can't put in interfaces -- specifically,
instance variables -- mean that you can inherit, ie, implement,
multiple interfaces without having to solve some knotty efficiency
issues.

If so
why would the language designers choose to include interfaces in the
language design when classes alone would have been sufficient

Premise false.

--
Chris "electric hedgehog" Dollin
"If there is a problem, you must confess it, Mr Chaplin."
Mr Carter, /The Beiderbeck Affair/

.



Relevant Pages

  • Re: which languages that support the construct "interface Foo : X {...}"
    ... interfaces need to be implemented by delegation, ... Type erasure makes Java's generics essentially worthless for ... The language designers went to a lot of effort ...
    (comp.object)
  • Re: which languages that support the construct "interface Foo : X {...}"
    ... interfaces need to be implemented by delegation, ... class Foo: public SomeTemplate ... Type erasure makes Java's generics essentially worthless for ... The language designers went to a lot of effort ...
    (comp.object)
  • Can Interfaces be mimicked with classes
    ... Can the functionality of interfaces be mimicked with classes?? ... why would the language designers choose to include interfaces in the ... language design when classes alone would have been sufficient ...
    (comp.lang.java.programmer)
  • Re: Can Interfaces be mimicked with classes
    ... sundarvenkata wrote: ... why would the language designers choose to include interfaces in the ... language design when classes alone would have been sufficient ... that interfaces allow multiple inheritance where classes don't. ...
    (comp.lang.java.programmer)
  • Re: dynamic type checking - a pauline conversion?
    ... to actually write the code in Java. ... Is the query handled ... One of the problems with Java typing is small differences in interfaces ... array iteration, List iteration, and database query result iteration all ...
    (comp.object)