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

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 • 802.91K Points
Coach

Q. How many Bytes are stored by ‘Long’ Data type in C# .net?

  • (A) 8
  • (B) 4
  • (C) 2
  • (D) 1

A

Admin • 802.91K Points
Coach

Q. Choose “.NET class” name from which data type “UInt” is derived?

  • (A) System.Int16
  • (B) System.UInt32
  • (C) System.UInt64
  • (D) System.UInt16

A

Admin • 802.91K Points
Coach

Q. Correct Declaration of Values to variables ‘a’ and ‘b’?

  • (A) int a = 32, b = 40.6;
  • (B) int a = 42; b = 40;
  • (C) int a = 32; int b = 40;
  • (D) int a = b = 42;

A

Admin • 802.91K Points
Coach

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

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();
 }
  • (A) ‘k’ should not be declared constant
  • (B) Expression assigned to ‘k’ should be constant in nature
  • (C) Expression (m * k) is invalid
  • (D) ‘m ‘ is declared in invalid format

A

Admin • 802.91K Points
Coach

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

  • (A) long < short < int < sbyte
  • (B) sbyte < short < int < long
  • (C) short < sbyte < int < long
  • (D) short < int < sbyte < long

A

Admin • 802.91K Points
Coach

Q. Which data type should be more preferred for storing a simple number like 35 to improve execution speed of a program?

  • (A) sbyte
  • (B) short
  • (C) int
  • (D) long

A

Admin • 802.91K Points
Coach

Q. Correct way to assign values to variable ‘c’ when int a=12, float b=3.5, int c;

  • (A) c = a + b;
  • (B) c = a + int(float(b));
  • (C) c = a + convert.ToInt32(b);
  • (D) c = int(a + b);

A

Admin • 802.91K Points
Coach

Q. Default Type of number without decimal is?

  • (A) Long Int
  • (B) Unsigned Long
  • (C) Int
  • (D) Unsigned Int

A

Admin • 802.91K Points
Coach

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

Code:
static void Main(string[] args)
 {
     float a = 10.553f;
     long b = 12L;
     int  c;
     c = Convert.ToInt32(a + b);
     Console.WriteLine(c);
 }
  • (A) 23.453
  • (B) 22
  • (C) 23
  • (D) 22.453

A

Admin • 802.91K Points
Coach

Q. Which of the following statements are TRUE about the .NET CLR?
1. It provides a language-neutral development & execution environment.
2. It ensures that an application would not be able to access memory that it is
not authorised to access.
3. It provides services to run "managed" applications.
4. The resources are garbage collected.
5. It provides services to run "unmanaged" applications.

  • (A) Only 1 and 2
  • (B) Only 1,2 and 4
  • (C) 1,2,3,4
  • (D) Only 4 and 5