Subject / 929 questions

Programming MCQs

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

Page 24 of 47

Question 463 C#

Which statement about the C# switch statement is true?

Correct answer D. Control cannot fall through from one non-empty case section to the next

Open question
Advertisement
Question 465 C#

What does the property pattern s is { Length: > 3 } test in C#?

Correct answer B. That s is not null and its Length property is greater than 3

Open question
Question 468 C#

What rule applies to an out parameter in C#?

Correct answer B. The method must assign it before returning; the caller need not initialise it

Open question
Question 469 C#

What does the in modifier on a C# method parameter mean?

Correct answer B. The argument is passed by reference but cannot be modified by the method

Open question
Advertisement
Question 471 C#

Which rule applies to optional parameters in C#?

Correct answer D. They must come after all required parameters and have compile-time constant defaults

Open question
Question 474 C#

Which requirement applies to declaring an extension method in C#?

Correct answer A. It must be a static method in a non-generic static class, with this before the first parameter

Open question
Question 475 C#

What is a local function in C#?

Correct answer C. A method declared inside another method and visible only within it

Open question
Advertisement
Question 476 C#

What is a key difference between a class and a struct in C#?

Correct answer A. A class is a reference type, while a struct is a value type copied on assignment

Open question
Question 480 C#

When does a static constructor run in C#?

Correct answer B. Once, automatically, before the first instance is created or any static member is accessed

Open question