Review Questions

   


1:

Why are there two ways to categorize the types in C#?

2:

Why does C# have other simple types than int?

3:

Which kind of attributes distinguish the different types from each other?

4:

What does it mean to be a strongly typed language like C#?

5:

Is it possible to assign a value of type int to a variable of type short, without an explicit conversion? Why or why not?

6:

How do you specify a literal to be of type float?

7:

Write a line of code that declares a private instance variable called distance, which is of type float and is initialized to 100.5.

8:

A variable of type byte is holding the value 255. The program now attempts to increment the value by one. What happens: If the compiler switch is set to unchecked? If it is set to checked?

9:

Which simple type would you use for a variable storing an arbitrary person's weight (in pounds)? (1 pound is approximately 0.45 kilos)?

10:

Which simple type would you use for storing account balances that would be involved in interest rate calculations requiring extremely high precision?

11:

Suppose myNumber and yourNumber are both of type float. Write a statement that adds these values together as ints and assigns them to an int variable.

12:

If number1 and number2 are of type int and text1 is of type string, what is the type of the following expression?

 number1 + text1 + number2 
13:

Is the following expression true or false when evaluated in C# and why? ((10 * 0.2f) == 2.0)

14:

When should you use constants in your source code? What are their advantages?

15:

Write a statement that prints 30000000.326m onscreen with this format: $30,000,000.33


   


C# Primer Plus
C Primer Plus (5th Edition)
ISBN: 0672326965
EAN: 2147483647
Year: 2000
Pages: 286
Authors: Stephen Prata

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net