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

Q 1 - Which of the following is a contextual keyword in C#?

A - get

B - set

C - add

D - All of the above.

Answer : D

Explanation

All of the above options are contextual keywords.

Answer : A

Explanation

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

Q 3 - Which of the following converts a type (integer or string type) to date-time structures in C#?

A - ToString

B - ToSingle

C - ToChar

D - ToDateTime

Answer : D

Explanation

ToDateTime() method converts a type (integer or string type) to date-time structures.

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 hide its member variables and member functions from other class objects and functions, except a child class within the same application?

A - Protected Internal

B - Private

C - Protected

D - Internal

Answer : A

Explanation

Protected Internal access specifier allows a class to hide its member variables and member functions from other class objects and functions, except a child class within the same application.

Q 7 - Which of the following is the default access specifier of a class?

A - Private

B - Public

C - Protected

D - Internal

Answer : D

Explanation

Default access specifier for a class type is Internal.

Answer : C

Explanation

Both of the above options are correct.

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


csharp_questions_answers.htm

Advertisements