• 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:

Marcus exam 3 q7

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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


 
Ranch Hand
Posts: 1467
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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).]
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
maha anna
Ranch Hand
Posts: 1467
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
If you try to please everybody, your progress is limited by the noisiest fool. And this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic