CSE2305 - Object-Oriented Software Engineering
Self Assessment Questions
For each question choose the single response which best answers the question, or which completes the statement most accurately.
Question 11: | What is "weak typing"? |
A physiological difficulty similar to RSI. |
When a computer language doesn't have a type mechanism |
When a computer language doesn't require a type mechanism |
When a computer language doesn't enforce its type mechanism |
When a computer language doesn't know about its type mechanism |
Question 12: | What is "strong typing"? |
A language is "strongly typed" if every object has a unique type |
A language is "strongly typed" if every object has a type which can be determined at compile-time |
A language is "strongly typed" if its various typing rules are strictly enforced without exception |
A language is "strongly typed" if its various typing rules are strictly enforced with only specified exceptions (e.g. casts) |
A language is "strongly typed" if its various keywords must be specified in UPPER CASE. |
Question 13: | What is "static typing"? |
Where the type of an object never changes ("is static") |
Where the type of an object is a fuzzy concept ("has static") |
Where the type of an object is determined at compile-time |
Where the type of an object is determined at run-time |
Where the type of an object is determined only in its definition file (i.e. like static variables and functions) |
Question 14: | What is "dynamic typing"? |
Better than 100 words per minute |
Where the type of an object is determined at compile-time |
Where the type of an object is determined at run-time |
Where the type of an object may change over time |
Where the type of an object may change at various points in the code |
Question 15: | Which kind of typing does C have? |
Weak static typing |
Weak dynamic typing |
Strong static typing |
Strong dynamic typing |
Strong weak typing |
Question 16: | Which kind of typing does C++ have? |
Weak static typing |
Weak static and dynamic typing |
Strong static typing |
Strong static and dynamic typing |
Weak strong typing |
Question 17: | What is "inheritance"? |
A relationship in which the structure and functionality of a class (the "child") is defined in terms of the structure and functionality of another (the "parent"). |
A relationship in which the structure and functionality of a class (the "parent") is defined in terms of the structure and functionality of another (the "child"). |
A relationship in which the structure of a class includes one or more instances of another. |
A relationship in which the functionality of a class makes calls to the functionality of another. |
All of the above |
Question 18: | Why is inheritance useful? |
Because it prevents inherited properties from being lost |
Because it minimizes the amount of code which has to be written |
Because it creates elegant tree structures |
Because it divides objects up into useful classes |
Because it prevents polymorphism |
Question 19: | In the C++ programming language what kinds of things can be inherited? |
Data members, function members, nested types, nested enums, friendship |
Data members, function members, nested types, nested enums, |
Data members, function members, |
Only data members |
Only function members |
Question 20: | What is the relationship called between a class and its public parent class? |
"...is a..." |
"...has a..." |
"...is implemented as a..." |
"...uses a..." |
"...becomes a..." |
Question 21: | What is the relationship called between a class and its private parent class? |
"...is a..." |
"...has a..." |
"...is implemented as a..." |
"...uses a..." |
"...becomes a..." |
Question 22: | What is "multiple inheritance"? |
When a parent class has two or more child classes |
When a base class has two or more derived classes |
When a child class has two or more parent classes |
When a child class has both an "is a" and a "has a" relationship with its parent class |
Where two classes inherit from each other |
Question 23: | Why do we say that multiple inheritance creates "directed acyclic inheritance graphs"? |
Because it sounds technical |
Because in the presence of multiple inheritance, inheritance hierarchies may no longer have a strict tree-like structure |
Because it is possible to draw a multiple inheritance relationship directly |
Because it is not possible to draw a multiple inheritance relationship directly |
Because in the presence of multiple inheritance, inheritance hierarchies must always form loops |
Question 24: | How does inheritance relate to abstraction? |
A base class is an abstraction of all its derived classes |
A derived class is an abstraction of all its base classes |
Base and derived classes are abstractions for each other |
Inheritance prevents abstraction |
There is no relationship between inheritance and abstraction |
Question 25: | What is the difference between public and private inheritance in C++ |
Publicly derived classes inherit only the public data members, whereas privately derived classes inherit only the private data members |
Publicly derived classes inherit both the public and private data members, whereas privately derived classes inherit only the private data members |
Public inheritance makes the public members of the base class public in the derived class; private inheritance makes public base class members private in the derived class |
Private inheritance changes the default accessibility for new members of a derived class to private: whereas public inheritance leaves the default for new members as public: |
Public inheritance represents an "is implemented as" relationship, whereas private inheritance represents an "is a" relationship |
Question 26: | Which is the correct syntax if we wish class D to publicly inherit from class B? |
class D: public: B {}; |
class D: public B {}; |
class D public: B {}; |
class B: public D {}; |
class B public: D {}; |
Question 27: | Why are private members of the base class not (directly) accessible in the derived class |
Because they're not inherited, so they don't exist in the derived class |
Because, if they were accessible, it would provide a way to break the encapsulation of a base class |
Because private members are not even accessible to the base class |
Because then there would be no use for the protected: keyword |
It's a trick question - they are directly accessible in the derived class. |
Question 28: | What is the accessibility of a protected: member of a base class which is inherited privately? |
private:, because the private inheritance makes everything from the base class private in the derived class |
protected:, because it wasn't public in the base class, it doesn't become private in the derived class |
public:, because accessibilities add: private: + private: = protected:, protected: + private: = public:, etc. |
Inaccessible. Private inheritance makes all non-public: members of the base class inaccessible in the derived class |
None. It's a compile-time error to privately inherit a protected: member |
Question 29: | If a derived-class object is created and later destroyed what is the order of the constructor and destructor calls on the object |
Base(), Derived(), ... , ~Base(), ~Derived() |
Derived(), Base(), ... , ~Derived(), ~Base() |
Base(), Derived(), ... , ~Derived(), ~Base() |
Derived(), Base(), ... , ~Base(), ~Derived() |
Derived(), ... , ~Derived() |
Last updated: July 18, 2005