• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

mockexam question.

 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Desperado
Posts: 3226
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 1467
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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).]
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
rubbery bacon. crispy tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic