View this PageEdit this PageAttachments to this PageHistory of this PageHomeRecent ChangesSearch the SwikiHelp Guide

Errors in Java Mediacomp Book

On page 396 it says
"was called at line 120 of the method toString in the class String."

It should say
"was called at line 120 of the method toString in the class Student."
found by Beth Simon

on p318 of your book, there is the following line of code:

Sound echoSound = new Sound (numEchoes delay + soundLength).

While there is a constructor for Sound (int numSeconds), I believe the comments / Javadoc are incorrect, in that it is NOT a file of n seconds, but rather a file of n samples.

I think you would have to also include the samplerate in the constructor in order to create in effect a silent sound of n samples at a given sample rate.

found by James Dale
James is right. The Sound(int number) is the number of samples.

On page 237 in the shear method there is a call to getTranslationEnclosingRectangle. It should be getTransformEnclosingRectangle instead.

found by Smith, Betty

On page 341 exercise 10.10 it should start the loop at
2* delay
2 * delay + 1
. This is from the Python book and indicies start at 1 in Python. In Java they start at 0.

Found by Barb Ericson

On page 423, you say that "The web is certainly not the penultimate
HyperText system."
I think you mean "ultimate" rather than "penultimate."
"Penultimate" means "next to last," and I think you mean "last"

Found by Dr. Barry I. Soroka [mailto:bisoroka at]

On page 138, the comment for the inner loop says
// loop from 1 to just before the mirror point

It should say:
// loop from 0 to just before the mirror point

On page 140, the same comment appears but this time, perhaps it should say:
// loop from 13 (the start of the pediment) to just before the mirror point

Found by Dr. Alvaro Monge [mailto:amonge at]

On page 158, the typesetting for the book got in the way. Just before the listing of Program 29, the text describes that "the target pixel's y value will be the width of the source picture - 1 - the source x (Figure 5.14).". The typesetting interpreted the minus symbols as dashes instead.

Found by Dr. Alvaro Monge [mailto:amonge at]

p. 103 section 4.3 (middle of the page) It is written "After the statements in the body of the loop are executed the index = index + 1; will be executed which will add one to the current value of index." This is misleading since the statement incrementing index is also in the body of the loop. While the while-loop flowchart highlighted this statement as being the last one in the body of the loop, it is still clearly in the body of the loop.Found by Dr. Alvaro Monge [mailto:amonge at]

p. 123 section 4.3.10 It is written "This is an overly simply notion of grayscale". It should say "simple
Found by Dr. Alvaro Monge [mailto:amonge at]

P. 149 section 5.2.2. It is written "We'll copy them all into the blank image 640x480.jpg". Two pages later at the bottom of page 151, however, the code uses a different blank image: String fileName = FileChooser.getMediaPath("7in95in.jpg");
Found by Dr. Alvaro Monge [mailto:amonge at]

On page 348 of Introduction to Computing and Programming with Java. You say, "“When one class inherits from another, it gets all the methods and fields from that parent class.” This is not correct, of course, and the emphasis on "all" is especially misleading to the reader. Neither class fields nor class methods are inherited. Even more seriously, private instance fields are not inherited. Here's what the Java authors say about this latter point:

A class inherits from its direct superclass and direct superinterfaces all the non-private fields of the superclass and superinterfaces that are both accessible to code in the class and not hidden by a declaration in the class.

Note that a private field of a superclass might be accessible to a subclass (for example, if both classes are members of the same class). Nevertheless, a private field is never inherited by a subclass. ( Gosling, James, Bill Joy, and Guy Steele. [1996], 2000. “8.3 Field Declarations,” Java Language Specification. 2d ed. Santa Clara, CA: Sun Microsystems, Ch. 8. (Accessed 14 April 2008). )

Since good programming practice demands that instance fields should generally be marked as private, the current wording in the book is confusing to the reader. I would recommend the following change: "When one class inherits from another, it gets all the accessible instance methods and fields from that parent class only. Constructors, class fields, class methods, and private instance fields are not inherited from the parent. If a child class wants to access a private field of its parent, it must do so like everybody else, viz., with the parent's getter and setter methods."

Found by Daryl Close []

Response by Barb Ericson

This is something that has bothered me for quite some time. I was teaching CS2 here at Georgia Tech with a book that said what you are saying above and it made no sense to me. The problem is what is meant by "inheritance". To me it means that a parent passes stuff on to a child (the general notion of inheritance). This is the main reason that we use inheritance in Java. We want to inherit the fields and methods from the parent class in order to reuse those. And Java does do this. If I create a parent class that has private fields and then create a subclass it will have the private fields as part of the object, so I would call that inheritance. It can not directly access the private fields, but that is due to the visibility of private. How else would the subclass object get the private field if it didn't get it by inheritance?

I think part of the problem here is that the definition of inheritance as far as programming is concerned isn't clear. Alan Kay says that he left inheritance out of the first Smalltalk because he didn't understand it. But, he also uses the definition of inheritance as getting the parents attributes (fields) and behaviors (methods).

I agree that class (static) fields and methods are not inherited.

I should change the book to say that object fields and methods are inherited. I should also mention that there is disagreement about inheritance of private instance fields.

Pages 486, 486,489, 491,493,496,and 498 use a replay method of FrameSequencer. It should just be play(). Also somewhere in chapter 14 it has FrameSequence instead of FrameSequenceer.
Found by James Dale

Link to this Page