C# Online Quiz


Advertisements


Following quiz provides Multiple Choice Questions (MCQs) related to C#. You will have to read all the given answers and click over the correct answer. If you are not sure about the answer then you can check the answer using Show Answer button. You can use Next Quiz button to check new set of questions in the quiz.

Questions and Answers

Answer : A

Explanation

When a value type is converted to object type, it is called boxing.

Q 3 - Which of the following converts a floating point or integer type to a decimal type in C#?

A - ToDecimal

B - ToDouble

C - ToInt16

D - ToInt32

Answer : A

Explanation

ToDecimal() method converts a floating point or integer type to a decimal type.

Q 4 - Which of the following operator casts without raising an exception if the cast fails in C#?

A - ?:

B - is

C - as

D - *

Answer : C

Explanation

as operator casts without raising an exception if the cast fails.

Q 5 - Which of the following access specifier in C# allows a class to expose its member variables and member functions to other functions and objects in the current assembly?

A - Public

B - Private

C - Protected

D - Internal

Answer : D

Explanation

Internal access specifier allows a class to expose its member variables and member functions to other functions and objects in the current assembly.

Q 6 - Which of the following property of Array class in C# gets a 64-bit integer, the total number of elements in all the dimensions of the Array?

A - Rank

B - LongLength

C - Length

D - None of the above.

Answer : B

Explanation

LongLength gets a 64-bit integer that represents the total number of elements in all the dimensions of the Array.

Answer : D

Explanation

All of the above options are correct.

Answer : C

Explanation

Both of the above options are correct.

Q 9 - 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 10 - 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.


csharp_questions_answers.htm

Advertisements