Previous Section  < Day Day Up >  Next Section

Chapter 2

A1:

A C# program must have an entry point defined by the static Main() method. It accepts a string array args as input.

A2:

// is used for single line comments; /* */ is used to enclose multi-line comments; and /// is used to create XML comments that can be exported to a text file.

A3:

A primitive refers to a simple value type such as an int or byte.

A4:


true


A5:

A do loop is evaluated at the end of the iteration and thus must execute at least once.

A6:

A break statement causes control to exit the enclosing loop immediately; a continue statement continues the same loop by skipping to the beginning of the loop.

A7:

a does not compile because an int cannot be converted to a char. c does not compile because a string cannot be converted to a char.

A8:

Each time concatenation occurs, a new string is created in memory. For a large number of concatenations, this wastes memory and also degrades performance. The StringBuilder class can be used as an alternative梑ut only where there are many concatenations. Otherwise, it will not outperform concatenation.

A9:

All classes inherit from System.Object. In addition, value types inherit from System.ValueType.

A10:

7

    Previous Section  < Day Day Up >  Next Section