O'Reilly logo

Beginning Object-Oriented Programming with C# by Jack Purdum

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Appendix

Answers to Exercises

Chapter 2

Exercise 1 Solution

A class is a body of code that contains properties and methods that describe an object. An object is an instance of a class that can be used in a program. Classes and objects are related in that a class is a template from which an object is created. They are different in that a class is not directly used in a program, whereas an object is.

Exercise 2 Solution

The Five Program Steps:

  • The Initialization step creates the environment in which the program is run.
  • The Input step is responsible for collecting all the information necessary for the program to accomplish its given task.
  • The Process step takes the data and acts on it in a way that accomplishes a given task.
  • The Output step presents the results of the Process step in a way that is useful to the user.
  • The Termination step is responsible for placing the program environment back to the state that prevailed before the program was run, updating any environment information that might be used the next time the program is run.

Exercise 3 Solution

The first statement defines a reference variable that you can use to access a clsThingie object. The second statement instantiates a clsThingie object and makes its properties and methods available through the reference variable named myThingie.

Exercise 4 Solution

A simple oven might have the following properties and methods:

// ================ Properties =================== int ovenTemp; // 0 is off, otherwise desired temperature ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required