• 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:
  • Devaka Cooray
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
Bartenders:

Doubt on practice exams - OCP Java by kathy sierra and barty bates

 
Greenhorn
Posts: 17
Slackware Flex Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
on page 133

54 Given:



Which are true? (Choose all that apply.)
A. Glanks have a Bostron.
B. Jookers implement Protefors.
C. Glanks implement Bostrons.
D. Jookers have a String.
E. Bostrons implement Vonks.
F. Bostrons have a Bostron.


Answer (for Objective 5.5):
 A, D, and F correctly describe some of the relationships within the code. Glanks have
Bostrons indirectly through Jookers. Jookers have Strings indirectly through Bostrons, and
Bostrons have Bostrons because it’s very common to want to make linked lists with your
Bostrons.
 B and E are incorrect because no such hierarchies exist in the code. C is incorrect because
Glanks “have” Bostrons (indirectly), but they don’t implement them.



in my first guess just F is correct... I've seen mock exams (MasterExam I think) that DOES NOT consider indirect relationships
I'm a little confused in what should I mark on the real exam
this means, Bostron have a String and not Jooker (Jooker have a Bostron)
on the real exam I should always consider indirect relationships?
thanks
 
Ranch Hand
Posts: 144
Netbeans IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi all ,

i also don't get it
what does it mean exactly by : Jookers have a String. ?
i think it would be correct if jooker had extended Bostron class or it could make an insatnce of Bostron class in the second case Bostron class should have been not
abstract...because we can not make insatnace of abstract classes
woudl anybody shows us with example how come we print out the string from the jooker class?
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, Glank has a Jooker and Jooker has a Bostron. So Glank has a Bostron.

Just as indirect IS-A relationships exist (Superclass - subclass - subsubclass), indirect HAS-A relationships can exist too.



So, A D F are correct. B E are not.
 
Ranch Hand
Posts: 207
jQuery Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Hama Kamal wrote:
i think it would be correct if jooker had extended Bostron class or it could make an insatnce of Bostron class in the second case Bostron class should have been not
abstract...because we can not make insatnace of abstract classes

woudl anybody shows us with example how come we print out the string from the jooker class?



But we can make instance of an anonymous subclass of abstract Bostron class, check this out:

So see no need to make Bostron class concrete (not abstract).
 
Ranch Hand
Posts: 394
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@Jeane...At the moment I have NOT read it in any official documentation that 'has-a' relatiosnhips CANNOT be hierarchical, the Oracle official mock exams I took a while ago had a similar question that meant 'has-a' CAN be indirect. I am pretty sure (or else otherwise proven) that for the purpose of the exams you should select options that encourage 'indirect-has-a'.

Hama wrote:would anybody shows us with example how come we print out the string from the jooker class?


Hello Hama, below is an example of how to take care of your doubts, you can use the same approach with interfaces
you need to practice a lot of code writing to keep you in good shape for the exams.

Output:

Regards

Ikpefua
 
Doody calls. I would really rather that it didn't. Comfort me wise and sterile tiny ad:
The new gardening playing cards kickstarter is now live!
https://www.kickstarter.com/projects/paulwheaton/garden-cards
reply
    Bookmark Topic Watch Topic
  • New Topic