Vidyalelo
C# Programming · all questions

Basic Syntax and Data Types in C Sharp
practice.

Practice every MCQ with options. Use Show answers when you want the correct option and solution.

115

Questions

4/6

Page

Pick an option on a question to see the right answer and solution.

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

Select an option to see the answer and solution.

What will be the output of the following C# code?
static void Main(string[] args)
{
    string s1 = "Delhi";
    string s2;
    s2 = s1.Insert (6, "Jaipur");
    Console.WriteLine(s2);
}

Select an option to see the answer and solution.

What will be the output of the following C# code?
static void Main(string[] args)
{
    { 
        var dayCode = "MTWFS";
        var daysArray = new List<string>();
        var list = new Dictionary<string, string>
        { {"M", "Monday"}, {"T", "Tuesday"}, {"W", "Wednesday"},
          {"R", "Thursday"}, {"F", "Friday"}, {"S", "Saturday"},
          {"U", "Sunday"}
        };
       for (int i = 0,max = dayCode.Length; i < max; i++)
       {
           var tmp = dayCode[i].ToString();
           if (list.ContainsKey(tmp))
           {
               daysArray.Add(list[tmp]);
            }
       }
       Console.WriteLine(string.Join("\n ", daysArray)); 
 }

Select an option to see the answer and solution.

Choose the correct type of variable scope for the following C# defined variables.
class ABC
{
    static int m;
    int n;
    void fun (int x , ref int y, out int z, int[] a)
    {
       int j = 10;
    }
}

Select an option to see the answer and solution.

Which is the String method used to compare two strings with each other?

Select an option to see the answer and solution.

What will be the output of the following C# code?
static void Main(string[] args)
{
     int i ;
     for (i = 0; i < 5; i++)
     {
         int j = 0;
         j += i; 
         Console. WriteLine(j);
     }
     Console. WriteLine( i * j);
     Console. ReadLine();
}

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

What is the Size of 'Char' datatype?

Select an option to see the answer and solution.

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();
}

Select an option to see the answer and solution.

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;
}

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

Verbatim string literal is better used for?

Select an option to see the answer and solution.

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();
}

Select an option to see the answer and solution.

Types of 'Data Conversion' in C#?

Select an option to see the answer and solution.

What will be the output of the following C# code?
static void Main(string[] args)
{
    int a = 5;
    int b = 10;
    int c;
    Console.WriteLine(c = a-- - ++b);
    Console.WriteLine(b);
    Console.ReadLine();
}

Select an option to see the answer and solution.

What will be the output of the following C# string? (Enter a String : BOMBAY).
static void Main(string[] args)
{
    string Str,  Revstr = " "; 
    int Length;
    Console.Write("Enter A String : ");
    Str = Console.ReadLine();
    Length = Str.Length - 1;
    while (Length >= 0)
    {
        Revstr = Revstr + Str[Length];
        Length --;
    }
    Console.WriteLine("Reverse  String  Is  {0}",  Revstr);
    Console.ReadLine();
}

Select an option to see the answer and solution.

The following C# codes are?
1. Myclass class;
   Myclass class2 = null;

2. int i;
   int j = 0;

Select an option to see the answer and solution.

Valid Size of float data type is?

Select an option to see the answer and solution.

The Default value of Boolean Data Type is?

Select an option to see the answer and solution.