My Report

C# Basic Online Test – 3


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. What is the need for 'Conversion of data type' in C#?

2. Type of Conversion in which compiler is unable to convert the data type implicitly is?

3. Which of the conversions are valid for the following C# code?

 static void Main(string[] args)
 {
     int a = 22;
     long b = 44;
     double c = 1.406;
     b = a;
     c = a;
     a = b;
     b = c;
 }

4. For the given set of C# code, is conversion possible?

 static void Main(string[] args)
 {
     int a = 76;
     char b;
     b = (char)a;
     Console.WriteLine(b);
     Console.ReadLine();
 }

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

static void Main(string[] args)
{
    float sum;
    int i;
    sum = 0.0F;
    for (i = 1; i <= 10; i++)
    {
        sum = sum + 1 /(float)i;
    }
    Console.WriteLine("sum =" +sum);
    Console.ReadLine();
}

6. 'Implicit Conversion' follows the order of conversion as per compatibility of data type as:

7. For the following C# code select the relevant solution for conversion of data type.

 static void Main(string[] args)
 {
     int num1 = 20000;
     int num2 = 50000;
     long total;
     total = num1 + num2;
     Console.WriteLine("Total is : " +total);
     Console.ReadLine();
 }

8. The subset of 'int' data type is __________

9. Disadvantages of Explicit Conversion are?

10. Types of 'Data Conversion' in 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.