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

3/6

Page

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

What is the correct syntax to declare a nullable integer variable in C#?

Select an option to see the answer and solution.

What is the purpose of the 'unchecked' keyword in C#?

Select an option to see the answer and solution.

What is the output of the following code: Console.WriteLine($"5 + 5 = {5 + 5}");

Select an option to see the answer and solution.

What is the correct way to declare and initialize a string variable in C#?

Select an option to see the answer and solution.

Which of the following is NOT a valid C# data type?

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

Syntax for declaration and initialization of data variable is?

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

Storage location used by computer memory to store data for usage by an application is?

Select an option to see the answer and solution.

For two strings s1 and s2 to be equal, which is the correct way to find if the contents of two strings are equal?

Select an option to see the answer and solution.

What will be the output of the following C# code?
int a,b;
a = (b = 10) + 5;

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

Correct statement about strings are?

Select an option to see the answer and solution.

What will be the output of the following C# code?
public static void Main(string[] args)
{
    int i = 546;
    object o = i;
    int n =(int) o;
    o = 70;
    System. Console. WriteLine("The value-type value = {0}", n);
    System. Console. WriteLine("The object-type value = {0}", o);
    Console. ReadLine();
}

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 a = 10.553f;
    long b = 12L;
    int  c;
    c = Convert.ToInt32(a + b);
    Console.WriteLine(c);
}

Select an option to see the answer and solution.