• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

inheritance

 
Ranch Hand
Posts: 234
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 234
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.  
 
My cellmate was this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic