My Report

C# Data Types Test – 2


Correct Answer: 2 points | Wrong: -1 point
Grades: A* (100% score) | A (80%-99%) | B (60%-80%) | C (40%-60%) | D (0%-40%)
advertisement

1. Valid Size of float data type is?

2. Minimum and Maximum range of values supported by 'float' data type are?

3. What will be the output of the following C# code?

static void Main(string[] args)
{
    int x = 1;
    float y = 2. 4f;
    short z = 1;
    Console. WriteLine((float) x + y * z - (x + = (short) y) );
    Console. ReadLine();
}

4. A float occupies 4 bytes. If the hexadecimal equivalent of these 4 bytes are A, B, C and D, then when this float is stored in memory in which of the following order do these bytes gets stored?

5. What will be the output of the following C# code?

 public static void Main(string[] args)
 {
     double ZERO = 0;
     Console.WriteLine("RESULT OF DIVISION BY ZERO IS :{0}",  (0 / ZERO));
     Console.ReadLine();
 }

6. Number of digits upto which precision value of float data type is valid?

7. What will be the correct set of C# code to display the value of given variable 'c' as '25.302'.

8. Select appropriate difference between decimal, float and double data type in C#?

i) Float and Double are floating binary point types while decimal is a floating decimal point type.
ii) Precision difference for float is '7' digit for double is '15' to '16' digit and for decimal is '28' to '29' digits.
iii) Some values which cannot be exactly represented hence for those values float and double are more appropriate.

9. Select a convenient declaration and initialization of a floating point number:

10. The Default value of Boolean Data Type is?

11. Why does a float variable stop incrementing at number '16777216' in the following C# code?

 float a = 0 ;
 while (true)
 {
     a++;
     if (a > 16777216)
     break;
 }

12. Which of the following format specifiers is used to print hexadecimal values and return value of output as Octal equivalent in C#?

13. Correct way to define a value 6.28 in a variable 'pi' where value cannot be modified?


 

Start practicing “1000 MCQs on C#”, and once you are ready, you can take tests on all topics by attempting our “C# Test Series”.

Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.