Instance data for a Java class


Instance data for a Java class


a) are limited to primitive types (e.g., int, double, char)

b) are limited to Strings

Lewis/Loftus/Cocking: Chapter 4 Test Bank TB 37

c) are limited to objects(e.g., Strings, classes defined by other programmers)

d) may be primitive types or objects, but objects must be defined to be private

e) may be primitive types or objects

Answer: e. Explanation: The instance data are the entities that make up the class and may be any type available whether primitive or object, and may be public or private. By using objects as instance data, it permits the class to be built upon other classes. This relationship where a class has instance data that are other classes is known as a has-a relationship.