My Report

C# Data Types Test – 1


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. Which data type should be more preferred for storing a simple number like 35 to improve execution speed of a program?

2. Which Conversion function of 'Convert.TOInt32()' and 'Int32.Parse()' is efficient?

i) Int32.Parse() is only used for strings and throws argument exception for null string
ii) Convert.Int32() used for data types and returns directly '0' for null string

3. How many Bytes are stored by 'Long' Data type in C# .net?

4. What will be Correct Set of C# Code for given data 'a' and 'b' to print output for 'c' as 74?

5. What will be the error in the following C# code?

 Static Void Main(String[] args)
 {
     const int m = 100;
     int n = 10;
     const int k = n / 5 * 100 * n ;
     Console.WriteLine(m * k);
     Console.ReadLine();
 }

6. Does the output remain same or different for both cases?
i)

  char l ='k';
  float b = 19.0f;
  int c;
  c = (l / convert.ToInt32(b));
  Console.Writeline(c);
  

ii)

   char l ='k';
   float b = 19.0f;
   int c;
   c = Convert.ToInt32(l / b);
   console.writeline(c);
  

7. Correct way to assign values to variable 'c' when int a=12, float b=3.5, int c;

8. Correct Declaration of Values to variables 'a' and 'b'?

9. Default Type of number without decimal is?

10. Choose ".NET class" name from which data type "UInt" is derived?

11. Arrange the following data type in order of increasing magnitude sbyte, short, long, int.

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

 static void Main(string[] args)
 {
     float a = 10.553f;
     long b = 12L;
     int  c;
     c = Convert.ToInt32(a + b);
     Console.WriteLine(c);
 }

 

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.