According to the Pro C# book, what are the two forms of code reuse?
Inheritance and containment/delegation
Inheritance can be described as what kind of relationship?
"is-a"
Containment/delegation can be described as what kind of relationship?
"has-a"
In .NET, is it safe to store an object of a derived class type within a base class reference?
Yes
What type of cast is it called in .NET when a derived class object is stored within a base class reference?
An implicit cast
What type of casting in .NET is why you can pass an object argument as a method parameter where the parameter is a parent class of the object's class?
Implicit casting
Is it possible in .NET to cast an object from a base class type to a derived type that is lower in the inheritance chain?
No
Hexagon h = item as Hexagon
What value will h have if item is not a type that can be explicitly cast to a Hexagon?
null
What instance method of System.Object compares items and, by default, only returns true if the items being compared refer to the same item in memory?
Equals()
If you override the System.Object Equals() method in C#, then what other method should you also override (because both of these methods are used internally by Hashtable types to retrieve subobjects from the container)?
GetHashCode()
When you build a class in C# that does not explicitly define its parent class, what is the parent class?
System.Object
What method of System.Object does ValueType override so that structures can do value-based comparisons?
Equals()
"For the time being, you can understand this method (when overridden) is called
to free any allocated resources before the object is destroyed."
What method of System.Object does this quote describe?
Finalize()
What method of System.Object returns an int that identifies a specific object instance?
GetHashCode()
What method of System.Object returns a string representation of the object using the fully qualified name (<namespace>.<type name>)?
ToString()
What keyword in C# is similar to as but it returns false instead of null when an explicit cast is not possible?
is
What method of System.Object returns a Type object that fully describes the object you are currently referencing (this is a runtime type identification method available to all objects)?
GetType()
What method of System.Object exists to return a member-by-member copy of the current object, which is often used when cloning an object?
MemberwiseClone()
What keyword does C# provides to quickly determine at runtime whether a given type is compatible with another (by checking against a null return value)?
as
What two keywords can you use in C# to trap the possibility of an invalid explicit cast resulting in a runtime exception?
try catch
When is explicit casting evaluated in .NET (at compile time or runtime)?
Runtime
What type of cast can you use in .NET when you know the object reference is pointing to a compatible class in memory but the compiler cannot?
An explicit cast
What is the ultimate base class in the .NET system?
System.Object
What are three terms for the existing class that serves as the basis for new classes in classical inheritance?
Base class, superclass, parent class
What are two terms for the extending classes in classical inheritance?
Derived class, child class
What is the operator that establishes an "is-a" relationship (inheritance) in C#?
:
Does a derived class inherit the constructor of a parent class in C#?
Never
What can be used/what is it called in C# to allow a constructor to be called by a derived class?
Constructor chaining
Does C# support multiple inheritance?
No
What is it called when a class in a programming language can have more than one direct parent class?
Multiple inheritance
What is the keyword in C# that prevents inheritance from occurring?
sealed
What category of types in C# is always sealed?
structure
What C# keyword can be used whenever a subclass wants to access (not override) a public or protected member defined by a parent class?
base
What happens to the default constructor in a C# class when a custom constructor is added to the class definition?
The default constructor is silently removed
What kind of C# members are directly accessible by any descendent of the class but outside the family, regarded as private?
Protected
What C# keyword can be used to specify that a class cannot be extended by other classes?
sealed
What is the act of adding public members to a class containing an object that use the contained object's functionality?
Delegation
Can non-nested classes be declared using the private keyword in C#?
No
What C# keyword is used on a method that may be, but does not have to be, overridden by a subclass?
virtual
What keyword does a child class in C# use when it wants to change the implementation details of a virtual method?
override
What keyword can be used to enforce that a parent class cannot have instances of it created in C#?
abstract
What keyword should be used in C# to define a method that does not provide a default implementation and must be accounted for in each derived class?
abstract
An abstract base class's polymorphic interface in C# refers to its what?
Set of virtual and abstract methods
If you were using a third-party package, and your subclass of a class from the package defined an identical member as the parent class, this is an example of what happening?
Shadowing
Previous card
First card
Random order
Next card