Wednesday, June 16, 2004

Exercise[16]

00:15 | 00:16 | 00:17

First read Concrete Point No. 3. Unless you enjoy torturing yourself, do not continue with the rest of this exercise until you feel very comfortable reading and executing the code in this article!

Now read the following posts (preferrably in order) and experiment with the JavaScript or Java code snippets they contain:
  1. An Abstract Point
  2. Concrete Point No. 1
  3. Concrete Point No. 2
Compose:
  1. Create a Java or JavaScript class called PointInSpace that models a point in three-dimensional space by extending the class PointInAPlane. Be sure to override the overloaded distanceFromOrigin method with a method that is appropriate for PointInSpace
  2. Use your class to create two or more objects representing actual points.
  3. Call your distanceFromOrigin method for each of the point objects you create.

Learn:
  1. What is a constructor?
  2. How do you define a constructor in JavaScript?
  3. What coding convention is typically used when identifying constructors in JavaScript, and how does this convention differ from the coding convention typically used when identifying other functions?
  4. How do you define a constructor in Java?
  5. How are Java constructors different from other Java methods?
  6. How may you call the constructor of a superclass from within the constructor of a subclass?
  7. What are the special methods named call and apply used for in JavaScript?
  8. How are the JavaScript methods call and apply similar and how are they different? 
  9. What does the keyword this mean in JavaScript?
  10. What does the keyword this mean in Java?
  11. What is a prototype object in JavaScript?
  12. What is the relationship between a prototype object and a __proto__ object in JavaScript?