Test 1 Review
The questions on Test 1 are based on the topics we have covered thus far in
class and used in Assignments 1 and 2. There is little (but more than zero)
about delegates or events. You should expect some mention of interfaces.
There is nothing about exceptions. There may be questions about Assignments
1 and 2.
The test includes true-false questions, multiple-choice questions, a
few short answer problems, and several coding questions. None of the
coding questions is large.
There are web pages and demonstration programs covering some of these topics.
You may find it useful to look at the quiz questions.
You should make sure you understand:
elementary stuff
- How do you declare and initialize an array? Or a 2-dimensional array?
- How is a jagged array different from a 2-dimensional array?
- What is a namespace in C#?
- Why do we need to write Console.WriteLine instead of WriteLine?
- What is a reference type? What is a value type?
- Are arguments passed to methods by value or by reference?
- What can you say about the String class?
- What is involved in sorting an array?
- What are collection classes?
- What are some differences between an array of double and a list of
double?
- If we use a StreamReader to read a file, how will we know when
we find the end of the file?
- What interface(s) have we used so far? What was involved?
- What would be an example of an illegal explicit cast?
properties
- What is a property?
- How is a property different from a data member?
- How is a property different from a method?
- Does a property always provide two kinds of access?
indexers
- What is an indexer?
- What kind of argument can an indexer have?
- Can w have more than one indexer for a class?
form applications
- Name four different kinds of form controls.
- What C# files are involved in a form application project?
- What ends the execution of a form application?
Suggested practice:
- Invent a class called Cylinder. It has two private data members, a double called
radius and a double called length. It should have public properties called
Radius and Length to give access to radius and length (get and set).
It should have public properties called Area and Volume to provide
the surface area and volume of the cylinder.
Write a constructor for the Cylinder class with two arguments (doubles).
Would it make sense to have a set accessor for Volume or Area?
- Suppose I have a struct called Machine which has two public data members: the ID
of a piece of equipment and the room number for the room containing it. Both
are of type String.
The Class HWList has two public data members: Building = the name of a building (a
String) and an array BList of Machine.
We will have variables of type HWList such as
HWList MyList;
and we would like to be able to refer to MyList[N] instead of MyList.BList[N] to
find a specific Machine on the list, and we would also like to be able to
find a Machine by starting with the equipment ID, so if an ID is "12345",
MyList["12345"] should return the Machine with that ID.
Write the code for the two indexers we need. You may assume the arguments will
be in bounds and you may assume ID numbers are unique.