Interface in Java

Status
Not open for further replies.

mikeshn

Ars Scholae Palatinae
1,447
I have a question about interface. For example I have Interface A with two functions: getName() and getAddress(). Than interface B with function getSalary(). Interface B is instance of interface A. Than class Professor that is subclass or instance of interface B.
I did the UML diagram on TogetherJ 4.02. My question is does is legal for class C implement the functions from interface A ((getName() or getAddress()).

Thanks a lot
 

R2P2

Ars Praefectus
3,783
Subscriptor
English isn't your first language, is it?

Anyway, from what I can make out from your description, your Java classes are something like this:

interface A
interface B extends A
Professor implements B
class C extends ? implements ?

If that's the case, then B inherits the methods defined by A, and Professor is required to implement all of those. So Professor *must* implement getName(), getAddress() and getSalary().

If C doesn't implement A or B, or extend Professor, then it can define its methods anyway it likes. ie. It can make getAddress() have a different return type then A says it should, because they are completely unrelated.
 
Status
Not open for further replies.