.net banner

.NET Multiple Choice Questions (MCQs) and Answers

Master .NET 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 .NET concepts. Begin your placement preparation journey now!

Q31

Q31 An application runs slowly due to frequent garbage collection. What could help improve performance?

A

Remove all variables

B

Optimize memory usage

C

Use fewer libraries

D

Disable garbage collection

Q32

Q32 What is the purpose of the .NET Framework Class Library (FCL)?

A

To manage memory

B

To provide a collection of reusable classes

C

To compile code

D

To store user data

Q33

Q33 What is an assembly in .NET?

A

A text file

B

A set of reusable code units

C

An HTML page

D

A user password

Q34

Q34 Which type of assembly can be shared across applications in .NET?

A

Private assembly

B

Global assembly

C

Local assembly

D

Static assembly

Q35

Q35 Which file extension is commonly used for .NET assemblies?

A

.dll

B

.exe

C

.cs

D

.html

Q36

Q36 What is the role of the Global Assembly Cache (GAC) in .NET?

A

Manages system memory

B

Executes code

C

Stores shared assemblies

D

Generates reports

Q37

Q37 What is the difference between an assembly and a namespace?

A

Assemblies organize code, namespaces compile code

B

Namespaces organize code, assemblies contain compiled code

C

Namespaces compile code, assemblies execute code

D

Assemblies store runtime data, namespaces create libraries

Q38

Q38 Which command would you use to install an assembly into the Global Assembly Cache?

A

install-gac assembly.dll

B

gacutil -i assembly.dll

C

addgac assembly.dll

D

import assembly.dll

Q39

Q39 How would you reference an external library in a .NET project?

A

import library.dll

B

using library;

C

AddReference library.dll

D

#include library.dll

Q40

Q40 In C#, which keyword is used to access classes from an external namespace?

A

load

B

import

C

using

D

reference

Q41

Q41 A developer encounters a "MissingAssemblyException." What could be a likely cause?

A

Incorrect file path

B

Corrupt CLR

C

Assembly not found

D

User permission error

Q42

Q42 How can you resolve a version conflict for an assembly in the GAC?

A

Reinstall .NET

B

Add assembly manually

C

Specify version in config file

D

Change project settings

Q43

Q43 An assembly fails to load due to version incompatibility. What could fix this issue?

A

Update assembly reference

B

Modify GAC

C

Delete library

D

Change system path

Q44

Q44 Which of the following is a value type in .NET?

A

string

B

int

C

object

D

dynamic

Q45

Q45 What is the default value of an integer variable in .NET?

A

null

B

0

C

1

D

undefined

Q46

Q46 Which data type can hold floating-point numbers in .NET?

A

int

B

float

C

char

D

bool

Q47

Q47 Which keyword in C# represents a data type that can hold any type of data?

A

var

B

dynamic

C

object

D

string

Q48

Q48 Which of the following data types is immutable in .NET?

A

int

B

StringBuilder

C

List

D

string

Q49

Q49 Which code snippet declares a boolean variable in C#?

A

bool isTrue = true;

B

boolean isTrue = true;

C

bool isTrue = 1;

D

bool isTrue: true

Q50

Q50 How would you declare a constant integer variable with a value of 10 in C#?

A

int constant = 10;

B

const int constant = 10;

C

constant int = 10;

D

readonly int constant = 10;

Q51

Q51 Which C# code snippet demonstrates declaring an array of integers?

A

int[] numbers = new int[5];

B

int numbers = new int;

C

int array numbers;

D

int[5] numbers;

Q52

Q52 A developer encounters an "OverflowException" when assigning a value. What could be the cause?

A

Incorrect type

B

Value exceeds data type limit

C

Syntax error

D

Null reference

Q53

Q53 A developer encounters a "NullReferenceException." What is the likely issue?

A

Variable is null

B

Memory leak

C

Data type mismatch

D

Invalid format

Q54

Q54 An integer variable is displaying unexpected values. What might be a possible cause?

A

Incorrect data type

B

Variable not initialized

C

Overflow

D

Syntax error

Q55

Q55 Which class is the base class for all exceptions in .NET?

A

ApplicationException

B

SystemException

C

Exception

D

ErrorException

Q56

Q56 What is the purpose of a try block in .NET?

A

To execute code unconditionally

B

To handle exceptions

C

To contain code that may throw exceptions

D

To store debug logs

Q57

Q57 Which block is used to execute cleanup code regardless of whether an exception occurs?

A

catch

B

finally

C

try

D

throw

Q58

Q58 Which of the following exceptions is thrown when accessing an array out of its bounds?

A

ArgumentException

B

IndexOutOfRangeException

C

OverflowException

D

DivideByZeroException

Q59

Q59 What is the purpose of the throw keyword in .NET exception handling?

A

To declare an exception

B

To log an exception

C

To pass an exception to higher-level code

D

To stop code execution

Q60

Q60 Which code snippet demonstrates handling a division by zero exception in C#?

A

try { int x = 10 / 0; }

B

try { int x = 10 / 0; } catch (DivideByZeroException ex) { }

C

int x = 10 / 0;

D

try { x = 10 / 0; }

ad verticalad vertical
ad