This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Marcus exam 3 q7 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Marcus exam 3 q7" Watch "Marcus exam 3 q7" New topic
Author

Marcus exam 3 q7

Venkat Raman
Greenhorn

Joined: Mar 04, 2000
Posts: 22
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 interface with 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 inheritance model, but require implementing classes to create the functionality of the Interfaces.
I answered as 2,4 but the answer key says it's only 4.
Any comments??
Venkat
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
I think only option 4 is correct. interface can have variables,which are implicitly static and final, you caN HAVE instance of interface,a class can extend one class but may may implement many interfaces, so that leaves option 4
correct me if i am wrong.
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Look at this: http://www.javaranch.com/ubb/Forum24/HTML/000926.html
I don't know if this is totally resolved yet. Marcus are you out there?
Jessie Huang
Greenhorn

Joined: Feb 17, 2004
Posts: 2
Would you please post the URL for marcus exam 3? Thanks a lot.
yellow
Originally posted by Venkat Raman:
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 interface with 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 inheritance model, but require implementing classes to create the functionality of the Interfaces.
I answered as 2,4 but the answer key says it's only 4.
Any comments??
Venkat

maha anna
Ranch Hand

Joined: Jan 31, 2000
Posts: 1467
yellow,
It is here http://www.jchq.net/mockexams/exam3.htm
Can you take few moments to register into JavaRanch.com. I feel somewhat odd to see people with strange names and when they are unregistered also. Though the treatment given is same for both. I hope you take it in a good sprit.
regds
maha anna
[This message has been edited by maha anna (edited April 02, 2000).]
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Answer 4 of MOCK 3 Q.7
"Interfaces require implementing classes to create the functionality of the interfaces".
is however questioning too..
I didn't select it. Here's why:
The interface 'serializable' is one of some empty interfaces.
It has no method at all, no variables either. Empty is empty.
But such interfaces do still have functionality, serving as flag "implements serializable", although they don't require implementing classes.
Can someone enlight me on this?
Thanks
[This message has been edited by JRoch (edited April 03, 2000).]
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
JRoch- you're thinking of a very small and unusual special case which can be interpreted several different ways. Note that the statement does not say "all" or "always" - it describes the general behavior of interfaces. And 99% of the time it's correct - that's good enough for me since it didn't say "always". Even if it had said "always" though, I think I would still agree with it. The type of "functionality" being talked about is implementing methods. If there aren't any methods to implement, it's meaningless to talk about whether they are "required" or not. The only "functionality" that Serializable has is that it allows "instanceof Serializable" to return true. You "implement" this functionality in a class the moment you write "implements Serializable" in the declaration - you've just implemented the interface. I don't think that counts as real "functionality", but if it does, then it's just as much work "implementing" it in a class as there is in declaring the interface it in the first place. The class was required to implement all the functionality of the interface, and it did, because there was no functionality other than the name itself, and the two words "implements Serializable" took care of that.
I hope that made sense. I think we could go in circles on this one indefinitely - it's easiest to just realize that this was not the sort of situation Marcus was thinking of when he wrote the test, and I doubt it's what the vast mojority of question readers were thinking of either. So it's best to just ignore this issue, I think.


"I'm not back." - Bill Harding, Twister
maha anna
Ranch Hand

Joined: Jan 31, 2000
Posts: 1467
I am also siding Jim. Just to finish up the discussion, JRoch has posted just part of the qstn. When I read the qstn completely, the context of the qstn makes the answer to be true I think. Marcus is just comparing this concept with that of multiple inheritance in Java. In Inheritance we are 'inheriting' the functionaly from super class as opposed in Interfaces where we have to define ourselves. SO if we see the qstn in this CONTEXT the answer is true.
regds
maha anna
<pre>
Marcus Exam 3 Qstn. 7)
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 interface with 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 its single inheritance model,
but require implementing classes to create the functionality of the Interfaces.

</pre>

[This message has been edited by maha anna (edited April 04, 2000).]
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Fair.
Jim pointed out "implementing".
There, was the source of my mistake and corresponding posting for enlightment on this: I was interpreting "defining" instead of "implementing" (hmm.. have you got smaller fonts!)
I had learned there was no obligation to have methods in interfaces (Serializable given as an example of such possible design). Thus "require" lured my attention.
Txs!
JRoch
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Marcus exam 3 q7
 
Similar Threads
mockexam question.
Marcus #3 Q7 Interfaces can have constructors?
Question on Interfaces
Question on Interfaces
interface