You are on page 1of 1

Week 4: Practical Exercises

After completing this session, you will be able to

         Understand Objects
o   Define a class containing a related set of methods and data items.
o   Control the accessibility of members by using the public and private keywords.
o   Create objects by using the new keyword to invoke a constructor.
o   Write and call your own constructors.
o   Create methods and data that can be shared by all instances of the same class by
using the static keyword.
         Understand Values and References
o   Explain the differences between a value type and a reference type.
o   Modify the way in which arguments are passed as method parameters by using
the ref and out keywords.
 
Detailed instructions to complete the practical exercises in this session are given in Chapter 7
and Chapter 8 of the book “Microsoft Visual C# 2010 Step by Step” by John Sharp, which is
available from of the University Library’s ebook collection.
To access the book, click the Web Links item on the left navigation menu on the CS6004
Weblearn page. Then click the item of the book on the Web link page. This will take you to the
University Library page to access the book. You will need your university username and
password to access the book.
Preparation:

         Download the project template for Exercises 1, 2 and 3 (Chapter7ExercisesCodeTemplate.zip)


         Download the project template for Exercises 4 and 5 (Chapter8ExercisesCodeTemplate)
Exercise 1
Write constructors and create objects, chapter 7, page 137
Exercise 2
Write and call instance methods, chapter 7, page 140
Exercise 3
Write static members, and call static methods, chapter 7, page 145
Exercise 4
Use value parameters and reference parameters, chapter 8, page 153
Exercise 5
Use ref parameters, chapter 8, page 161
When you are done, please demonstrate your projects to your tutor.

You might also like