文件名称:数据结构从应用到实现(java版)课后习题答案
文件大小:946KB
文件格式:DOC
更新时间:2014-03-27 13:21:25
数据结构从应用到实现(java版)
Exercise Solutions to Data Structures Outside in with Java By Hongbiao Zeng Chapter 1 E1.1. a) Two states: frequency, volume. Two methods: set volume, get frequency. b) Two states: length, text. Two methods: set text, get length. c) Two states: center, radius. Two methods: set center, get radius. d) Two states: names of two roads that intersect. Two methods: get roads’ names, set roads’ names. e) Two states: car price, car mileages. Two methods: set price, get mileages. f) Two states: type, speed. Two methods: set type, get speed. E1.2. Static field is used to store a class-wide shared resource. E1.3. Static methods can be used as a utility method, controlling the number of instances. The special static method main is the entry point of a program. E1.4. A static method cannot reference a non-static field in its class. Because the non-static field must associate with an instance of the class but the static method can be called even when no instances of the class have be created. A non-static method can reference a static field since the static field is shared by every instance of the class.