my dog learned polymorphism*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes K&B: :Page 14 Default Access - misleading sentence Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply locked New topic
Author

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

Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
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 ]

Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Naseem Khan
Ranch Hand

Joined: Apr 25, 2005
Posts: 809
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


    Asking Smart Questions FAQ - How To Put Your Code In Code Tags
    Bert Bates
    author
    Sheriff

    Joined: Oct 14, 2002
    Posts: 8829
        
        5


    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?


    Spot false dilemmas now, ask me how!
    (If you're not on the edge, you're taking up too much room.)
    Arno Reper
    Ranch Hand

    Joined: Mar 14, 2006
    Posts: 286
    perfect...


    The man who makes no mistakes does not usually make anything<br /> <br />>>> SCJP 5.0 >> SCJD B&S <<< In progress
     
    jQuery in Action, 2nd edition
     
    subject: K&B: :Page 14 Default Access - misleading sentence