GIGO: words unreadable aloud
Mishrogo Weedapeval
 

 

  Thursday 10 June 2004
Chapter 5, Exercise 7

Change the class Cookie as specified in the section labeled "protected: inheritance access". Verify that bite() is not public.

package x;
class Cookie {
  Console.println("Cookie constructor");
  protected def bite = Console.println("bite"); 
}
object c5x7 {
    def main ( args: Array[String] ) = {
        val x = new Cookie;
        x.bite;
    }
}

scalac responds with the following error message:

c5x7.scala:12: method bite cannot be accessed in x.Cookie
        x.bite;
         ^
one error found

12:09:28 AM   comment/     


Click here to visit the Radio UserLand website. Click to see the XML version of this web page. © Copyright 2007 Doug Landauer .
Last update: 07/2/6; 12:40:42 .
Click here to send an email to the editor of this weblog.

June 2004
Sun Mon Tue Wed Thu Fri Sat
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30      
May   Jul

Previous/Next