C# online quiz

1agcgj

Following quiz provides Multiple Choice Questions (MCQs) related to C#. You will have to read all the given answers and choose over the correct answer. If you are not sure about the answer then you can check the answer using Show Answer link.

1. Which of the following variable types can be assigned a value directly in C#?

A – Value types
B – Reference types
C – Pointer types
D – All of the above

Show Answer
Answer: A
Explaination: Value type variables can be assigned a value directly.

2. Which of the following is correct about value type variables in C#?

A – The value types directly contain data.
B – int, char, and float, which stores numbers, alphabets, and floating point numbers, respectively are value types.
C – When you declare an int type, the system allocates memory to store the value.
D – All of the above.

Show Answer
Answer: D
Explaination: All of the above options are correct.

3. Which of the following converts a type to a 16-bit integer in C#?

A – ToDecimal
B – ToDouble
C – ToInt16
D – ToInt32

Show Answer
Answer: C
Explaination: ToInt16() method converts a type to a 16-bit integer.

4. Which of the following operator returns the type of a class in C#?

A – sizeof
B – typeof
C – &
D – *

Show Answer
Answer: B
Explaination: typeof() operator returns the type of a class.

5. Which of the following access specifier in C# allows a child class to access the member variables and member functions of its base class?

A – Public
B – Private
C – Protected
D – Internal

Show Answer
Answer: Π‘
Explaination: Protected access specifier allows a child class to access the member variables and member functions of its base class.

6. Which of the following is true about C# structures?

A – Structures can have methods, fields, indexers, properties, operator methods, and events.
B – Structures can have defined constructors, but not destructors.
C – You cannot define a default constructor for a structure. The default constructor is automatically defined and cannot be changed.
D – All of the above.

Show Answer
Answer: D
Explaination: All of the above options are correct.

7. Which of the following is the default access specifier of a class member variable?

A – Private
B – Public
C – Protected
D – Internal

Show Answer
Answer: A
Explaination: Default access for the class member variables is Private.

8. Which of the following is the correct about interfaces in C#?

A – Interfaces are declared using the interface keyword.
B – Interface methods are public by default.
C – Both of the above.
D – None of the above.

Show Answer
Answer: C
Explaination: Both of the above options are correct.

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

Show Answer
Answer: C
Explaination: #if βˆ’ It allows testing a symbol or symbols to see if they evaluate to true.

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

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

 

One thought on “C# online quiz

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s