Subject / 929 questions

Programming MCQs

Page 23 of Programming multiple-choice questions with answers. Tap an option to check yourself.

Page 23 of 47

Question 441 C#

When does a finally block execute in C#?

Correct answer B. After the try block and any catch, whether or not an exception occurred, even after return

Open question
Question 442 C#

Inside a catch block, what is the difference between throw; and throw ex;?

Correct answer B. throw; keeps the original stack trace, while throw ex; resets it to the current point

Open question
Question 443 C#

What does the C# using statement guarantee for an object such as a StreamReader?

Correct answer A. Its Dispose method is called when the block is exited, even if an exception is thrown

Open question
Advertisement
Question 444 C#

What is the purpose of implementing IDisposable in a C# class?

Correct answer B. To give callers a Dispose method that releases unmanaged or expensive resources deterministically

Open question
Question 445 C#

What is a delegate in C#?

Correct answer D. A type-safe reference to a method with a specific signature

Open question
Advertisement
Question 451 C#

What does the event keyword add when applied to a delegate field in a C# class?

Correct answer C. Outside code can only subscribe with += and unsubscribe with -=, not invoke or replace it

Open question
Question 453 C#

What does default(T) produce in a C# generic method?

Correct answer B. null for reference types and the zero value for value types

Open question
Advertisement