Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

inheritance

 
Jason Attin
Ranch Hand
Posts: 232
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys, here is a question from Glenn, Mitchell. OCAJP Oracle Certified Associate Java SE 8 Programmer Practice Exams (Kindle Locations 7523-7531). Enthuware. Kindle Edition.
What can be inserted in the code below so that it will print UP UP UP?

Select 2 options
A.
B.
C.
D.
E.


Correct answers are A and C. Why A?
I mean s reference type is Speak which has no relation with the interface, so in this case the reference doesn't matter but the class of the object (GoodSpeak) does?
 
timothy adigun
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I mean s reference type is Speak

Yes, but it object type is GoodSpeak which is a typeof Tone, since class GoodSpeak implements interface Tone.

Insert these code:

 
Jason Attin
Ranch Hand
Posts: 232
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for the code, it's is great, I tried it and everything prints true. But for the exam I have to be able to spot this right away. So, is it OK to say that what matters isn't the reference of the object but the class it belongs to (like in this case GoodSpeak?)
thanks
 
timothy adigun
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jason Attin wrote:thanks for the code, it's is great, I tried it and everything prints true. But for the exam I have to be able to spot this right away. So, is it OK to say that what matters isn't the reference of the object but the class it belongs to (like in this case GoodSpeak?)
thanks


The options B, D and E were wrong because we can't call the method up() on that reference. 
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic