Home > Articles > Programming > C#

  • Print
  • + Share This
This chapter is from the book

This chapter is from the book

Workshop

The Workshop is designed to help you anticipate possible questions, review what you've learned, and get you thinking about how to put your knowledge into practice. The answers to the quiz are in Appendix A, "Answers to Quizzes/Exercises."

Quiz

  1. To create objects, you must first create a template. This template is called a:

  2. One of the primary benefits of object-oriented programming is that objects contain both their data and their code. This is called:

  3. With static classes, public variables and routines are always available to code via the static class in other modules. Is this true with public variables and routines in classes?

  4. True or False: Each object derived from a class has its own set of class-level data.

  5. What must you do to create a property that can be read but not changed by client code?

  6. What is the best way to store the internal value of a property within a class?

  7. Which is generally superior, early binding or late binding?

  8. What is the best way to release an object you no longer need?

Exercises

  1. Add a new property to your class called DropsInABucket. Make this property a Long, and set it up so that client code can read the property value but not set it. Finally, add a button to the form that, when clicked, prints the value of the property to the Output window. When this is working, modify the code so that the property always returns 1,000,000.

  2. Add a button to your form that creates two object variables of type clsMyClass(). Use the new keyword to instantiate a new instance of the class in one of the variables. Then set the second variable to reference the same object and print the contents of the Height property to the Output window.

  • + Share This
  • 🔖 Save To Your Account