1 / 12

Chapter 4

Chapter 4. Solutions to Review Questions. 4.1 Define object , class and instance . The UML Glossary gives these definitions: Object: an instance of a class. Class: a classifier that describes a set of objects that share the same specifications of features, semantics and constraints.

erv
Download Presentation

Chapter 4

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 4 Solutions to Review Questions

  2. 4.1 Define object, classandinstance. The UML Glossary gives these definitions: • Object: an instance of a class. • Class: a classifier that describes a set of objects that share the same specifications of features, semantics and constraints. • Instance: an entity that has unique identity, a set of operations that can be applied to it, and state that stores the effect of the operations (also object instance).

  3. 4.2 What do youthink is meantby ‘semantics’? • Semantics is the study of meaning. • In object-oriented development it is used to denote themeaningthat an element has for the user. • The semantics of an object include its purpose, description, relationships and behaviour seen from a user perspective.

  4. 4.3 Howdoestheobject-orientedconcept of messagepassinghelptohidetheimplementation of an object, includingits data? • Other parts of a system only see an object’s interface (services it can perform and operation signatures). Internal details including data are hidden and can only be accessed by a message that contains a valid signature.

  5. 4.4 What is polymorphism? • Polymorphism means that when one message is sent to objects of different types, each has an appropriate, but different, implementation for its response. The object that sends the message need not know which type of object is addressed. One way of implementing polymorphism is through inheritance and overriding.

  6. 4.5 What’sthedifferencebetweengeneralizationandspecialization? • Generalization and specialization are opposite sides of the same coin. As we look further up an inheritance hierarchy, the classes become more generalized in their application. As we look down the same hierarchy, they become more specialized. For example Employee is more generalized than HourlyPaidEmployee, while the latter is more specialized.

  7. 4.6 Whatrulesdescribetherelationshipbetween a subclassanditssuperclass? • A subclass inherits all characteristics of its ancestors or superclasses (some superclass characteristics may be overridden, but are still technically inherited). Each subclass is different from its ancestor superclasses in at least one way.

  8. 4.7 Whatdoes it meanto say that an object-orientedsystem is highlymodular? • Objects are likely to be cohesive (that is, reasonably simple and having a single purpose), well-encapsulated and relatively weakly coupled to other objects in the system. This is equivalent to saying that they are highly modular. They may also be assembled into larger composition and component structures, which are themselves highly modular.

  9. 4.8 Why is it particularly hard for a designertoanticipate a user’ssequence of taskswhenusing a GUI application? • The interface for a typical GUI application (for example, a word processor that runs in a windowing environment) consists of many buttons, tools and menu choices. The user can usually select any of these whenever she wishes, and the software designer must cater for this flexibility of use.

  10. 4.9 Whatdoes ‘objectstate’ mean? • A condition in the life of an object during which it behaves in a particular way, e.g. waiting for some event or performing some activity. The state of an object also determines the way that it responds to events.

  11. 4.10 What is an operationsignature? • An operation signature gives the format of a valid message that will cause the operation to execute.

  12. 4.11 Distinguishbetween ‘encapsulation’ and ‘informationhiding’ • Encapsulation means that operations are located together with the data that they act upon. i.e. in the same object. Information hiding means that the implementation of an object’s data is hidden from all other objects, and can only be accessed by that object’s operations. Information hiding is a much stronger design principle, since some object-oriented languages allow encapsulation to be bypassed.

More Related