Exercises


  1. What is wrong with the following code?

     public sealed class MyClass { // Class members. } public class myDerivedClass : MyClass { // Class members. } 
  2. How would you define a noncreatable class?

  3. Why are noncreatable classes still useful? How do you make use of their capabilities?

  4. Write code in a class library project called Vehicles that implements the Vehicle family of objects discussed earlier in this chapter, in the section on interfaces versus abstract classes. There are nine objects and two interfaces that require implementation.

  5. Create a console application project, Traffic, which references Vehicles.dll (created in question 4). Include a function called AddPassenger() that accepts any object with the IPassengerCarrier interface. To prove that the code works, call this function using instances of each object that supports the interface, calling the ToString() method inherited from System.Object on each one and writing the result to the screen.




Beginning Visual C# 2005
Beginning Visual C#supAND#174;/sup 2005
ISBN: B000N7ETVG
EAN: N/A
Year: 2005
Pages: 278

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net