• 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

Test Question classes and packages (Java OCA 8 Programmer I Study Guide, Sybex)

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I am reading a study guide for the OCA 8 exam. The book says the following code will compile. I think it won't due to a name conflict on 'Water', but don't currently have a pc to test it. Also it is 3 separate classes, so I can't test it online. Please can someone test it for me?

Much appreciated.





 
Ranch Hand
Posts: 35
3
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!

It will compile since both classes Water are in different packages.
When you make a reference of Water in WaterFilter, you are importing all classes of the package "aquarium", but not "aquarium.jellies". So only the first Water will be used in WaterFilter.
That's why it compiles
 
RichardH Marais
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you
 
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch

Please always use the code button; I shall go back and edit the code for you, and you'll see how much better it looks Also make sure to indent the code correctly … or when copying from a certification book, indent the code exactly as in the book. They like to print misleading or incorrect indentation in some of those books, to try and catch you out.
 
reply
    Bookmark Topic Watch Topic
  • New Topic