Com S 362 --- Object-Oriented Analysis and Design EXERCISE: OBJECTS AND CLASSES 2 (File $Date: 2003/09/03 05:05:56 $) The purpose of this exercise is for you to learn some key facts about Java objects and classes. As with all exercises, this is to be done individually, not in teams. And it is due the day this topic is planned to be discussed in class, unless specified otherwise (see the syllabus at: http://www.cs.iastate.edu/~cs362/syllabus.shtml). As with all exercises, you have two choices for doing the work. You can either: - complete it as specified or - write down questions or problems that you had in trying to complete it. If you write down questions or problems you have, these should be detailed enough so that we can tell that you have read the materials and thought about them. (Don't just write: "I couldn't get it to work; say what you tried and what you didn't understand.) During the class where this exercise is discussed, you should try to get help with these by explaining what you did and what your problems or confusions are. Don't be shy; there will be other people with the same problem, and everyone can learn by discussing these issues. 1. [Object Creation Semantics] Read sections 1.7.1 and 2.4-2.5 of Ken Arnold, James Gosling, and David Holmes's book The Java Programming Language Third Edition (Addison-Wesley, Reading, Mass., 2000). Explain, using a picture of the run-time stack and the heap, what happens during the execution of an object creation expression, such as new Vehicle(currentSpeed, currentDirection, ownerName) in Java. 2. [Static vs. Instance in Java] Read sections 1.7.2, 1.8.3, 2.2.2, and 2.6.1 of Ken Arnold, James Gosling, and David Holmes's book The Java Programming Language Third Edition (Addison-Wesley, Reading, Mass., 2000). (a) Briefly describe the difference between a non-static (instance) field and a static (class) field. (a) Briefly describe the difference between a non-static (instance) method and a static (class) method. WHAT TO HAND IN You should have at the beginning of class, written answers to the above questions (or written out questions and problems you encountered for each part). Make sure your name is on these. Attach the printouts, if any, requested above. ADDITIONAL READINGS If you are new to Java you might also want to read the interesting (to you) parts of the "new to Java" section on-line at http://developer.java.sun.com/developer/onlineTraining/new2java/ (If you read that link, I would advise starting with the "step by step programming" step, which is step 3.)