Get your CodeRanch badge!*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes mockexam question. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "mockexam question." Watch "mockexam question." New topic
Author

mockexam question.

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
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
Desperado
Sheriff

Joined: Jan 30, 2000
Posts: 3222
    
    5
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.


Tony Alicea
Senior Java Web Application Developer, SCPJ2, SCWCD
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
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.
Nilesh Parikh
Ranch Hand

Joined: Mar 14, 2000
Posts: 52
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
Ranch Hand

Joined: Jan 31, 2000
Posts: 1467
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
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
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.


"I'm not back." - Bill Harding, Twister
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: mockexam question.
 
Similar Threads
Marcus Exam 3 #7
mock question
Question on Interfaces
interface
Question on Interfaces