Previous Section  < Day Day Up >  Next Section

4.8. Test Your Understanding

1:

What are the advantages of using a class factory to create objects?

2:

Which class should custom exceptions inherit from? Which constructors should be included?

3:

How does the default System.Object.Equals method determine if two objects are equal?

4:

Which interface(s) must a class implement in order to support the foreach statement?

5:

What is the main advantage of using generics?

6:

What is the purpose of implementing IDisposable on a class?

7:

Refer to the following code:


public class test: ICloneable

{

   public int Age;

   public string Name;

   public test(string myname)

   { Name = myname;    }

   public Object Clone()

   { return MemberwiseClone(); }

}

// Create instances of class

test myTest = new test("Joanna");

myTest.Age = 36;

test clone1 = (test) mytest.Clone();

test clone2 = myTest;


Indicate whether the following statements evaluate to TRue or false:

  1. 
    Object.ReferenceEquals(myTest.Name, clone1.Name)
    
    

  2. 
    Object.ReferenceEquals(myTest.Age, clone1.Age)
    
    

  3. 
    myTest.Name = "Julie";
    
    Object.ReferenceEquals(myTest.Name, clone1.Name)
    
    

  4. 
    Object.ReferenceEquals(myTest.Name, clone2.Name)
    
    

8:

How does implementing Finalize on an object affect its Garbage Collection?

    Previous Section  < Day Day Up >  Next Section