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

K&B: :Page 14 Default Access - misleading sentence

 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
On page 14, at the top, there is an example of a class Tea in package exam.stuff trying to extend another class Beverage in package cert.

Later there is a paragraph:


Tea won't compile because its superclass, Beverage, has default access and is in a different package. Apart from using fully qualified class names, which we'll cover in Chapter 10, you can do one of two things to make this work.



Now I come to the point. The phrase "Apart from using fully qualified class names, which we'll cover in Chapter 10," seems to imply that using fully qualified class names will solve this access problem. It won't: only putting both classes in the same package or making class Beverage public will solve the problem. Using a fully qualified class name cert.Beverage is just an alternative to importing the Beverage class.

Is there anybody who has the book who agrees with my point of view?
[ July 22, 2006: Message edited by: Barry Gaunt ]
 
Ranch Hand
Posts: 809
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
I think you are right Barry.

The phrase "Apart from using fully qualified class names, which we'll cover in Chapter 10," looks like Author is trying to say that there is some third way of compiling the Tea class even if Beverage is in a different package from the subclass Tea besides these two ways:

  • Putting both class in the same package.
  • Declaring Beverage class public.



  • But there is no third way. You have to put both class in same package or declare Beverage public.


    Naseem
     
    author
    Posts: 9050
    21
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Report post to moderator


    We need a new emoticon...for when you have to fall on your sword :roll:

    This bad, bad sentence:

    Apart from using fully qualified class names, which we'll cover in Chapter 10, you can do one of two things to make this work.



    Should simply be:

    You can do one of two things to make this work.



    Sound good?
     
    Ranch Hand
    Posts: 286
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Report post to moderator
    perfect...
     
      Bookmark Topic Watch Topic
    • New Topic