7.7. Exercises

  1. Test yourself: run through the following list of OO terms—some formal, some informal—and see whether you can define each term in your own words without referring to the text:

    Abstract classClassDerived class
    Abstract methodClass hierarchyDictionary
    AbstractionClass variableEncapsulation
    Accessor (of a property)ClassificationField
    Accessor methodClient (object)Generalization
    AggregationClient codeGeneric class
    Ancestor classCollection classGet accessor
    AssociationComposite classGet method
    Base classConstantGetter
    Behavioral relationshipConstructorInformation hiding
    Binary associationDelegationInheritance
    InstanceOperationSet method
    Instance variableOrdered listSetter
    InstantiationOverloadingSibling class
    InterfaceOverridingSimple type
    Local variableParent classSorted ordered list
    Leaf nodePolymorphismSpecialization
    LinkPredefined typeState
    MemberPrivate accessibilityStatic field
    MethodPublic accessibilityStatic method
    Method headerReferenceStatic variable
    Method signatureReference variableStructural relationship
    ModelingReflexive associationSupplier (object)
    Multiple inheritanceRoot (of a class hierarchy)Unary association
    MultiplicitySet (collection)User-defined type
    Object (in the software sense)Set accessor 

  2. Which fields, belonging to which SRS classes, might be well suited to being declared as static?

  3. It has been argued that the capability to declare and implement interfaces in the C# language eliminates the need for derived classes to inherit from multiple base classes. Do you agree or disagree? Why? Can you think of any ways in which implementing multiple interfaces "falls short" as compared with true multiple inheritance?

  4. The following client code scenarios would each cause compilation errors—can you explain why this is so in each case? Be as precise as possible as to the reasons—they might not be as obvious as first meets the eye!

    Assume that Professor and StudentTeacher are both classes that implement the ITeacher interface.

    Scenario #1:

    Professor p;
    StudentTeacher s = new StudentTeacher();
    ITeacher t;
    
    t = s;
    p = t;

    Scenario #2:

    Professor p = new Professor();
    StudentTeacher s;
    ITeacher t = new StudentTeacher();
    
    s = t;

    Scenario #3:

    Professor p = new Professor();
    StudentTeacher s = new StudentTeacher();
    ITeacher t;
    
    p = t;

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset