C# (C Sharp) MCQs with answers Page - 18

Here, you will find a collection of MCQ questions on C# (C Sharp). Go through these questions to enhance your preparation for upcoming examinations and interviews.

To check the correct answer, simply click the View Answer button provided for each question.

Have your own questions to contribute? Click the button below to share your MCQs with others!

+ Add Question

A

Admin • 833.24K Points
Coach

Q. What is the Size of ‘Char’ datatype?

  • (A) 8 bit
  • (B) 12 bit
  • (C) 16 bit
  • (D) 20 bit

A

Admin • 833.24K Points
Coach

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

Code:
static void Main(string[] args)
{
    string s1 = "Delhi";
    string s2;
    s2 = s1.Insert (6, "Jaipur");
    Console.WriteLine(s2);
}
  • (A) DelhJaipuri
  • (B) Delhi Jaipur
  • (C) Delhi
  • (D) DelhiJaipur

A

Admin • 833.24K Points
Coach

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

  • (A) if(s1 = s2)
  • (B) int c; c = s1.CompareTo(s2);
  • (C) if (s1 is s2)
  • (D) if(strcmp(s1, s2))

A

Admin • 833.24K Points
Coach

Q. What will be the output of the following C# string? (Enter a String : BOMBAY).

Code:
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();
}
  • (A) BOMBA
  • (B) YABMOB
  • (C) BOMAYB
  • (D) YABMO

A

Admin • 833.24K Points
Coach

Q. Correct statement about strings are?

  • (A) a string is created on the stack
  • (B) a string is primitive in nature
  • (C) a string is primitive in nature
  • (D) created of string on a stack or on a heap depends on the length of the string

A

Admin • 833.24K Points
Coach

Q. Verbatim string literal is better used for?

  • (A) Convenience and better readability of strings when string text consist of backlash characters
  • (B) Used to initialize multi-line strings
  • (C) To embed a quotation mark by using double quotation marks inside a verbatim string
  • (D) All of the mentioned

A

Admin • 833.24K Points
Coach

Q. Why strings are of reference type in C#.NET?

  • (A) To create string on stack
  • (B) To reduce the size of string
  • (C) To overcome problem of stackoverflow
  • (D) None of the mentioned

A

Admin • 833.24K Points
Coach

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

Code:
static void Main(string[] args)
 {
     int a = 5;
     int b = 10;
     int c;
     Console.WriteLine(c = ++ a + b ++);
     Console.WriteLine(b);
     Console.ReadLine();
 }
  • (A) 11, 10
  • (B) 16, 10
  • (C) 16, 11
  • (D) 15, 11

A

Admin • 833.24K Points
Coach

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

  • (A) Pointers
  • (B) Constants
  • (C) Variable
  • (D) None of the mentioned

A

Admin • 833.24K Points
Coach

Q. DIFFERENCE BETWEEN KEYWORDS ‘VAR’ AND ‘DYNAMIC’?

  • (A) ‘Var’ is introduced in C# (3.0) and ‘Dynamic’ is introduced in C# (4.0)
  • (B) ‘Var’ is a type of variable where declaration is done at compile time by compiler while ‘Dynamic’ declaration is achieved at runtime by compiler
  • (C) For ‘Var’ Error is caught at compile time and for ‘Dynamic’ Error is caught at runtime
  • (D) All of the mentioned

Add MCQ in this Category

If you want to share an MCQ question in this category, it's a great idea! It will be helpful for many other students using this website.

Share Your MCQ