Home arrow static arrow Java Programming [Archive] - Question regarding Inrefaces:Please GUIDE.
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - Question regarding Inrefaces:Please GUIDE.
This topic has 17 replies on 2 pages.    « Previous | 1 | 2 |

Posts:24,036
Registered: 2/3/03
Re: Question regarding Inrefaces:Please GUIDE.  
Aug 9, 2004 10:20 AM (reply 15 of 17)



 
From the [url=http://www.javaworld.com/jw-01-2001/jw-0119-type.html]JLS[/url]:

There are three kinds of reference types: class types (�8), interface types (�9), and array types (�10).
 
Guest
Re: Question regarding Inrefaces:Please GUIDE.  
Aug 9, 2004 10:34 AM (reply 16 of 17)



 

as simply being called a Collection does not make it
a type.

Your interpretation doesn't seem to jive with the
language specification, which specifically refers to
interfaces as "types".

"Type" and "Class" are not necessarily synonymous:
http://www.javaworld.com/jw-01-2001/jw-0119-type.html

A String is a type which is comparable. But using it
as a comparable does not tell you its type -
just the behaviour, which leads me to think that a
String "is a" Comparable, is not right.

String is a class. Comparable is an interface. Both
are "types". In common usage among Java programmers,
implementing an interface imparts an "is-a"
relationship.

Yes, I was misinterpreting the word type.
 

Posts:3,258
Registered: 00-08-28
Re: Question regarding Inrefaces:Please GUIDE.  
Aug 9, 2004 11:33 AM (reply 17 of 17)



 
I think of interfaces as a 'view' of an implementation
(class). A class that implements an interface does not
have an "is a" relationship with the interface, even
if the instanceof operator works.

An interface is a definition of (one type of) behavior
of the class, and a class can exibit several different
'types of' behaviors, by implementing several
interfaces.

It definitely has to have in "is -a " relationship in order to implement an interface else you are violating some of the basic principles of OOP. As a matter fact a lot of Gurus including James Gosling prefer using interfaces than class inheritance just to strengthen the whole inheritance hierarchy or "is a" phenomenon

 
This topic has 17 replies on 2 pages.    « Previous | 1 | 2 |