C# Mock Test



This section presents you various set of Mock Tests related to C#. You can download these sample mock tests at your local machine and solve offline at your convenience. Every mock test is supplied with a mock test key to let you verify the final score and grade yourself.

Questions and Answers

C# Mock Test IV

Q 1 - Dynamic polymorphism is implemented by abstract classes and virtual functions.

A - true

B - false

Answer : A

Explanation

Dynamic polymorphism is implemented by abstract classes and virtual functions.

Q 2 - The comparison operators can be overloaded.

A - true

B - false

Answer : A

Explanation

The comparison operators can be overloaded.

Q 3 - The conditional logical operators can be overloaded.

A - true

B - false

Answer : B

Explanation

The conditional logical operators cannot be overloaded.

Q 4 - The assignment operators cannot be overloaded.

A - true

B - false

Answer : A

Explanation

The assignment operators cannot be overloaded.

Answer : C

Explanation

Both of the above options are correct.

Q 7 - You can define one namespace inside another namespace.

A - true

B - false

Answer : A

Explanation

You can define one namespace inside another namespace. You can access members of nested namespace by using the dot (.) operator.

Q 8 - Which of the following preprocessor directive defines a sequence of characters as symbol in C#?

A - define

B - undef

C - region

D - endregion

Answer : A

Explanation

#define: It defines a sequence of characters, called symbol.

Q 9 - Which of the following preprocessor directive allows you to undefine a symbol in C#?

A - define

B - undef

C - region

D - endregion

Answer : B

Explanation

#undef: It allows you to undefine a symbol.

Q 10 - Which of the following preprocessor directive allows testing a symbol or symbols to see if they evaluate to true in C#?

A - define

B - undef

C - if

D - elif

Answer : C

Explanation

#if − It allows testing a symbol or symbols to see if they evaluate to true.

Q 11 - Which of the following preprocessor directive allows to create a compound conditional directive, along with #if in C#?

A - define

B - elif

C - if

D - else

Answer : D

Explanation

#else − It allows to create a compound conditional directive, along with #if.

Q 12 - Which of the following preprocessor directive allows creating a compound conditional directive in C#?

A - elif

B - define

C - if

D - else

Answer : A

Explanation

#elif − It allows creating a compound conditional directive.

Q 13 - Which of the following preprocessor directive specifies the end of a conditional directive in C#?

A - elif

B - endif

C - if

D - else

Answer : B

Explanation

#endif − Specifies the end of a conditional directive.

Q 14 - Which of the following preprocessor directive lets you modify the compiler's line number and (optionally) the file name output for errors and warnings in C#?

A - elif

B - endif

C - line

D - region

Answer : C

Explanation

#line − It lets you modify the compiler's line number and (optionally) the file name output for errors and warnings.

Q 15 - Which of the following preprocessor directive allows generating an error from a specific location in your code in C#?

A - define

B - region

C - line

D - error

Answer : D

Explanation

#error − It allows generating an error from a specific location in your code.

Q 16 - Which of the following preprocessor directive allows generating a level one warning from a specific location in your code in C#?

A - warning

B - region

C - line

D - error

Answer : A

Explanation

#warning − It allows generating a level one warning from a specific location in your code.

Q 17 - Which of the following preprocessor directive lets you specify a block of code that you can expand or collapse when using the outlining feature of the Visual Studio Code Editor in C#?

A - warning

B - region

C - line

D - error

Answer : B

Explanation

#region − It lets you specify a block of code that you can expand or collapse when using the outlining feature of the Visual Studio Code Editor.

Q 18 - Which of the following preprocessor directive marks the end of a #region block in C#?

A - warning

B - region

C - endregion

D - error

Answer : C

Explanation

#endregion − It marks the end of a #region block.

Answer : C

Explanation

Both of the above options are correct.

Q 21 - The finally block is used to execute a given set of statements, whether an exception is thrown or not thrown.

A - true

B - false

Answer : A

Explanation

The finally block is used to execute a given set of statements, whether an exception is thrown or not thrown.

Answer : C

Explanation

Both of the above options are correct.

Answer : C

Explanation

Both of the above options are correct.

Q 24 - The System.SystemException class is the base class for all predefined system exception in C#?

A - true

B - false

Answer : A

Explanation

The System.SystemException class is the base class for all predefined system exception.

Q 25 - User-defined exception classes are derived from the ApplicationException class in C#?

A - true

B - false

Answer : A

Explanation

User-defined exception classes are derived from the ApplicationException class.

Answer Sheet

Question Number Answer Key
1 A
2 A
3 B
4 A
5 C
6 D
7 A
8 A
9 B
10 C
11 D
12 A
13 B
14 C
15 D
16 A
17 B
18 C
19 C
20 C
21 A
22 C
23 C
24 A
25 A
csharp_questions_answers.htm
Advertisements