|
CIS162AD -- C Sharp (C#) -- Section 5832
Professor: Dave Hammer dwhammer@cox.net http://members.cox.net/dwhammer/ Student: Patrick Moss patmoss@patmoss.com http://www.patmoss.com/cis162ad/ Quiz #1 Due Thursday, February 16, 2006
I. Definitions
1. hardware (p. 799)
The physical devices of a computer system that you can touch.
Cf. software
2. RAM = random-access memory (p. 804)
The device that holds a computer's instructions and data.
Also commonly called main memory. RAM is "volatile" and
loses its information when the power is turned off.
3. IDE = Integrated Development Environment (p. 800)
A program environment, such as Visual Studio .NET, in which
you type your source code statements, debug, compile, and run
your application.
4. Unicode (p. 807)
The character set used by programmers of C#. The Unicode
character set uses 16 bits to represent a character. Thus
2**16 = 65,536 unique characters can be represented.
5. top-down design (p. 806)
A design methodology that divides a problem into a number
of sub-problems. Each sub-problem is then further subdivided
into smaller units until the method is manageable. Also
called divide and conquer approach or step-wise refinement.
6. pseudocode (p. 804)
A tool used during the program design stage to develop an
algorithm. As the name implies, with pseudocode, steps are
written in "pseudo" or approximate code format, which looks
like English statements.
7. data type (p. 88-94)
The values types are often called the fundamental data types
or primitive data types of the language. The C# value data
types include:
byte, sbyte, char, decimal, double, float, int, uint, long,
ulong, short, ushort, bool.
C# also has two built-in reference types:
string and object.
8. method (p. 802)
How behaviors are implemented in C#. Similar to functions
found in other languages.
9. constructor (p. 158-160)
When you instantiate a class, you actually create an instance
of the class, an object that takes up space and exists. It is
through a special method, called a constructor, that you use
to create instances of a class. Constructors differ from other
methods in two ways:
a. Constructors do not return a value, but the keyword void
is not included.
b. Constructors use the identifier as the class name.
A public access modifier is always associated with constructors
so that other classes can instantiate objects of their type.
Constructors are often overloaded. A default constructor is
provided with each instantiated object. You can write additional
constructors to overload the default constructor.
10. bool (p. 93-94)
The only Boolean type in C# is bool. A bool variable can have
a value of either true or false. The variable can be declared
as follows:
bool moreData = true;
The bool type will not accept integer values such as 0, 1, or
-1. The keywords true and false are built into the C# language
and are the only allowable values.
II. Questions or short essay
1. What is the difference between system software and application
software?
Years ago, there was no system software. We had to provide the
software to control a computer, such as a compiler and and
debugger and a loader. And our application program had to
include all drivers to control input/output peripherals.
For PCs, since the advent of DOS and then Windows, for desktop
computers, we first load an operating system, such as Windows
XP. This operating system controls all of the hardware functions
associated with the computer. It also may include compilers, and
debuggers, and loaders, etc.
When we write an application program (such as a payroll program,
or an A/R program, or a statistical analysis program, etc.),
we use a GUI IDE (system software) to enter and test the source
program, then we create an distributable executable .EXE version
of the object program.
Then we give the .EXE version, together with operating instructions,
to a customer. Then the customer runs the application software
on their computer.
2. What is the difference between object-oriented programming and
procedural programming?
When using procedural programming, we typically implement an
algorithm, in a main programming loop, that carries out the
step-by-step procedure to implement the program specification.
When using object-oriented programming, we break the problem down
into smaller parts. Then we design (or use an already available)
Class to provide each smaller part of the solution. Then we test
each Class (if it is a newly developed Class). Then we instantiate
each Class to form objects in our application program. This is
sometimes called the "black box" approach to software design.
Each class contains encapsulated methods and data. The user
can only provide input data to and receive output data from the
"black box".
3. What is a reference data type?
In C#, there are value data types and reference data types.
Please see I.7. above. For a value type, the memory address of
each variable is the actual memory address that contains the data
value. For a reference type, the memory address of each variable
is just a reference to the first memory address of the location
that actually contains the data item.
The built-in reference types in C# are string and object. (p. 94)
4. From where in the program can you access private members? (p. 132)
Access to private members is limited to the containing class.
When a class or a class member does not specify a modifier, a
default accessibility level of private is assumed.
5. What does the void keyword specify? (p. 49)
If a method does not return a value, the void keyword is included
to signal that no value is returned.
6. What is an overloaded method? (p. 803)
Multiple methods with the same name, but each method has a
different number or type of parameter.
III. Programming Exercise
Write a class named Circle with fields named radius, area, and
diameter. Include a constructor that sets the radius to 1. Also
include public methods named SetRadius(), GetDiam(), GetArea(),
ComputeDiameter() which computes a circle's diameter, and
ComputeArea() which computes a circle's area. (The diameter of a
circle is twice the radius. The area is Pi (3.14) times the square
of the radius.) Turn in your source code for this program.
|