File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes About IS-A relationships needing two classes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "About IS-A relationships needing two classes" Watch "About IS-A relationships needing two classes" New topic

About IS-A relationships needing two classes

Thomas Kennedy
Ranch Hand

Joined: Jan 20, 2008
Posts: 137
The question came up whether an IS-A relationship requires two classes, and the answer I got back was that yes, they do. But is an interface a class? My understanding is that interfaces, not supporting constructors, are not to be considered classes. Discuss...

Costs matter. Justice lies in processes not outcomes. Crime is caused by criminals.
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24199

Discussions about the "is-a" relationship are by definition conceptual and language-independent. If you use the word "class" in such a discussion, it's not the same as the Java keyword "class", which refers to a specific language feature.

If you want to have the same discussion specifically in the context of Java, you could either be pedantic and say "class, interface, or enum" whenever you mean "class" -- or you can just continue to say "class" and let it be understood that you mean that in the broader, object-oriented design sense.

[Jess in Action][AskingGoodQuestions]

Joined: Mar 02, 2002
Posts: 4
Is-a relationship happens when there are two classes.When we say ObjectA is a Object B, it invloves two classes .
Interface is not class, but it is blue print of what you can do with the objects of the class that implements that interface.
Eg. if we take a set of alphnumeric keys as an interface.
The interface has english alphabets, numbers and soem extra keys.
The computer class when implements this interface we use it in a bit diferent way as comaped if it is implemented by a cell phone class.
We cannot say a cell phone is a computer because it implements the same interface.
This is a weak relationship we can say cellphone is a kind of computer.

On the other hand.
If we have class called Processor.
Computer extends Processor and PDA also extends Processor.

so we can ssay PDA is a Computer.Its a strong relationship and we are usign two class for it.
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10828

We do have a naming policy here at the ranch which is not optional.
Your screen name must consist of a first name and last name which must not be obviously fictitious.
Please note, user accounts not adhering to the naming policy stand a good chance of getting suspended.
You are expected to adjust your your screen name before you post next.

[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24199

Originally posted by alpa_pathak:
Is-a relationship happens when ...

Nope, total bosh. See my post above.
I agree. Here's the link:
subject: About IS-A relationships needing two classes
It's not a secret anymore!