Tik-76.138 Ohjelmistometodiikka - tentti 2.10.1995

Tik-76.138 Programming methodology - examination 2 October 1995

Merkitse koepaperiin kurssin nimi, päivämäärä, koko nimesi, koulutusohjelma ja opintokirjan numero. [Write the following information on your paper: The name of the course, date, your full name, your study programme and your study book number.]

1/4. Selitä lyhyesti seuraavat käsitteet (tai anna esimerkki) : [Explain briefly the following concepts (or give an exampIe):] (max 6 p.)

(a) Abstrakti kantaluokka [Abstract base class]

(b) Automaattinen muistinhallinta eli roskankeruu [Automatic memory management or garbage collection]

(c) Vahva tyypitys [Strong typing]

(d) C++ -luokan staattinen jäsen [Static member of a C++ class]

(e) Funktion ylikuormitus C++:ssa [Function overloading in C++]

(f) Inline-funktio C++:ssa [Inline function in C++]

2/4. Kerro kustakin käskystä 1-6 onko käsky sallittu vai kielletty. Kukin oikea vastaus: +1 p., tyhjä vastaus: 0 p. väärä vastaus: -1 p. [For each the following statements 1-6 tell whether the statement is valid or invalid. Each correct answer: +1 p, empty answer: 0 p., wrong answer: - 1 p.] (max 6 p.)

class A

{

public:

void a_publ();

protected:

void a_prot();

private:

void a_priv();

};

class B : public A

{

public:

void b_publ();

protected:

void b_prot();

private:

void b_priv();

};

void

B::b_publ ()

{

a_prot(); // (1)

a_priv(); // (2)

b_priv(); // (3)

}

B b;

b.a_publ(); // (4)

b.b_publ(); // (5)

b.b_prot(); // (6)

3/4. Mitkä kysymykset on ratkaistava, kun oliokieleen lisätään moniperintä? Kuinka nämä kysymykset on ratkaistu C++:ssa? [Which questions must be answered when multiple inheritance is added to an object-oriented programming language? How are these questions answered in C++?] (max 6 p.)

4/4. Piirrä mielekäs OMT-notaation mukainen oliokaavio, jossa käytetään seuraavia käsitteitä [Use the OMT notation to draw a sensible object diagram that contains the following concepts] (max 6 p.) :

· olioluokka [object class]

· olioluokan attribuutti [object class attribute]

· perintä [inheritance]

· 1:N-yhteys luokkien välillä [one-to-many association between classes]

· M:N-yhteys luokkien välillä [many-to-many association between classes]

· kooste [aggregation]

· yhteyden attribuutti [link attribute]