Review Questions



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


Why does C# have other simple types than int?


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


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


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


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


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


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?


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


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


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.


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 

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


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


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 © 2008-2017.
If you may any questions please contact us: