Subject / 929 questions

Programming MCQs

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

Page 22 of 47

Question 422 C#

What does the await operator do in a C# async method?

Correct answer C. It suspends the method until the awaited task completes, without blocking the thread

Open question
Advertisement
Question 426 C#

What is the purpose of attributes such as in C#?

Correct answer D. To attach declarative metadata to code elements that tools or reflection can read

Open question
Question 428 C#

What does a file-scoped namespace declaration such as namespace MyApp.Models; do in C# 10 and later?

Correct answer C. It places every type in the file into that namespace without an extra pair of braces

Open question
Question 429 C#

Which statement about partial classes in C# is true?

Correct answer C. All parts must use the partial keyword and be in the same assembly and namespace

Open question
Advertisement
Question 433 C#

Which statement about an abstract class in C# is true?

Correct answer A. It cannot be instantiated directly and may contain abstract members without bodies

Open question
Question 434 C#

What does the sealed modifier do when applied to a C# class?

Correct answer A. It prevents other classes from inheriting from it

Open question
Advertisement
Question 437 C#

Where is a member marked protected internal accessible in C#?

Correct answer D. Anywhere in the same assembly, or in derived classes in any assembly

Open question
Question 439 C#

What does an init accessor, as in public string Name { get; init; }, allow in C#?

Correct answer D. The property can be set only during object initialisation, then becomes read-only

Open question