Chapter 3, Programming Languages

Q1

A. public, because we want to access it from Main class which is outside the Book class.

Q1

A. JavaScript will think this is an error because we try to access .length from an undefined value. This is because JavaScript can't get a property value from an undefined value.

Q1

A. Circle is a class because it has the definition, and circle is an object, instantiated from the Circle class.

Q1

A. Just add printAuthor in the Book class prototype, and then all objects created from Book will have the function. If we put the method in every instantiated object, it would be too cumbersome to do it, while having it on prototype guarantees that the method is always created.