Author Topic:   mockexam question.
javagirl
unregistered
posted March 22, 2000 07:37 PM           
Question 7 in Marcus's exam3

Which of the following statements are true?

1) An interface can only contain method and not variables
2) Java does not allow the creation of a reference to an
interfacewith the new keyword.
3) A class may extend only one other class and implement only
one interface
4) Interfaces are the Java approach to addressing the single
inheritancemodel, but require implementing classes to create the
functionality ofthe Interfaces.

The answer is 4.

I thought Interfaces are the Java approach to addressing the
multiple inheritancemodel.Java can't support extending more than
one class but it supports implementing more than one interface .
Aren't we making multiple inheritance possible through
interfaces???

Could somebody please clarify regarding that fourth option in the
above question.

Thanks.

Tony Alicea
sheriff
posted March 22, 2000 07:52 PM             
With interface inheritance you are only inheriting SIGNATURES of methods. You have to do the rest of the work (as in implementing those methods). With class inheritance you inherit all implemented behaviour (methods) from the superclass.

As a Lao-Tze-Not said: Interfaces in Java are the "POOR MAN'S MULTIPLE CLASS INHERITANCE" way of doing that sort of thing.

javagirl
unregistered
posted March 22, 2000 08:15 PM           
Thanks for your reply tony. But my question is.
Isn't the fourth option in the above question suppose to be.

Interfaces are the Java approach to addressing the "MULTIPLE
INHERITANCE MODEL", but require implementing classes to create the functionality ofthe Interfaces.

But instead it says.

Interfaces are the Java approach to addressing the "SINGLE
INHERITANCE MODEL", but require implementing classes to create the functionality of the Interfaces.

please clarify. i am confused.

THANKS.

Alkesh Nandanwar
ranch hand
posted March 22, 2000 09:09 PM             
hi
I think the wording that marcus used is correct. Interfaces are their in java to address the SINGLE inheritence model, which is there in c++.
We are changing our approach by introducing Interfaces.
Hope this helps
Alkesh

maha anna
bartender
posted March 22, 2000 09:45 PM             
javagirl,
What you think/I think/ and the qstn asks are all same. The qstn essentially says this. Java is based on single inheritance class model.A class cannot extend more than one class at a time. (i.e) the extends keyword can be followed by maximum 1 class. So this is considered as a lack in Java and this peoblem is addressed by means of allowing a class to implement more than 1 interface. So the wording of the qstn is ok I think.
regds
maha anna

[This message has been edited by maha anna (edited March 22, 2000).]

Jim Yingst
sheriff
posted March 23, 2000 11:43 AM             
Like javagirl, I'd be happier if the question said "multiple" rather than "single" - but I guess it's a matter of perspective : is the glass half full or half empty? Interfaces are the java approach to addressing the difference between the single inheritance model, which Java has, and the multiple inheritance model, which Java does not have, but which many people wanted Java to support in some way.

|