C# banner

C# Multiple Choice Questions (MCQs) and Answers

Master C# with Practice MCQs. Explore our curated collection of Multiple Choice Questions. Ideal for placement and interview preparation, our questions range from basic to advanced, ensuring comprehensive coverage of C# concepts. Begin your placement preparation journey now!

Q1

Q1 What is C# primarily used for in the .NET ecosystem?

A

System Programming

B

Web Development

C

Mobile Apps

D

All of the above

Q2

Q2 Who developed C#?

A

Microsoft

B

Google

C

Apple

D

IBM

Q3

Q3 Which of the following is a feature of C#?

A

Platform dependent

B

Garbage collection

C

Weakly typed

D

None of the above

Q4

Q4 In which year was C# first released?

A

2000

B

2002

C

2005

D

2008

Q5

Q5 What type of language is C#?

A

Procedural

B

Functional

C

Object-oriented

D

All of the above

Q6

Q6 Which of the following best describes the .NET framework?

A

A hardware component

B

An operating system

C

A development platform

D

A database management system

Q7

Q7 Which language influenced the development of C# the most?

A

Java

B

Python

C

C++

D

PHP

Q8

Q8 What is the primary runtime used to execute C# programs?

A

JVM

B

CLR

C

Python Interpreter

D

None of the above

Q9

Q9 Which of the following is the correct way to start a C# console application?

A

public static void Main() { }

B

public void Main() { }

C

static void Main() { }

D

void Main() { }

Q10

Q10 If you receive a 'namespace not found' error, what is the likely cause?

A

Incorrect file extension

B

Missing 'using' directive

C

Typo in the class name

D

Missing semicolon

Q11

Q11 Which keyword is used to define a constant in C#?

A

constant

B

const

C

readonly

D

static

Q12

Q12 What is the correct syntax for a single-line comment in C#?

A

// comment

B

/* comment */

C

<!-- comment -->

D

# comment

Q13

Q13 Which of the following is a valid identifier in C#?

A

1variable

B

_variable

C

variable#

D

@variable

Q14

Q14 How do you declare an integer variable in C#?

A

int number;

B

integer number;

C

var number;

D

int: number;

Q15

Q15 Which keyword is used to prevent a class from being inherited in C#?

A

sealed

B

static

C

final

D

private

Q16

Q16 What is the output of 'Console.WriteLine(10 % 3);' in C#?

A

1

B

2

C

3

D

0

Q17

Q17 How do you define a method in C#?

A

void MethodName() { // code }

B

method MethodName() { // code }

C

void MethodName[] { // code }

D

function MethodName() { // code }

Q18

Q18 How do you write a 'for' loop in C#?

A

for (int i = 0; i < 10; i++) { }

B

for (int i = 0; i < 10) { }

C

for i in range(10): { }

D

for i = 0 to 9 { }

Q19

Q19 How do you create a new instance of a class in C#?

A

MyClass obj = new MyClass();

B

MyClass obj();

C

MyClass obj = MyClass();

D

new MyClass obj;

Q20

Q20 You get a 'missing semicolon' error.
What is the likely cause?

A

A line of code is missing a semicolon at the end

B

Incorrect class definition

C

Invalid variable declaration

D

Incorrect use of a keyword

Q21

Q21 You encounter a 'syntax error' in your C# code.
What could be the possible reason?

A

Missing brackets

B

Misspelled keywords

C

Incorrect use of operators

D

All of the above

Q22

Q22 Which of the following is a value type in C#?

A

String

B

Object

C

Int

D

Array

Q23

Q23 What is the default value of a boolean variable in C#?

A

true

B

false

C

0

D

null

Q24

Q24 Which of the following is a reference type in C#?

A

int

B

float

C

double

D

string

Q25

Q25 What is the size of an 'int' data type in C#?

A

2 bytes

B

4 bytes

C

8 bytes

D

16 bytes

Q26

Q26 What is the difference between 'int' and 'double' in C#?

A

'int' is for integer values, 'double' is for floating-point values

B

'int' is for small numbers, 'double' is for large numbers

C

'int' is a reference type, 'double' is a value type

D

'int' is an immutable type, 'double' is a mutable type

Q27

Q27 Which data type would you use for a variable that needs to store a large text?

A

char

B

string

C

StringBuilder

D

Text

Q28

Q28 How would you define a constant integer in C#?

A

constant int x = 10;

B

const int x = 10;

C

readonly int x = 10;

D

static int x = 10;

Q29

Q29 Which of the following is the correct way to assign a value to a variable in C#?

A

int x = 10;

B

int x == 10;

C

int x := 10;

D

int x -> 10;

Q30

Q30 How do you declare a character variable in C#?

A

char letter = 'A';

B

char letter = "A";

C

char letter = A;

D

char letter = 65;

...
ad verticalad vertical
ad