HomeCode HereC# control flow quiz C# control flow quiz Admin 1 min read Updated November 16, 2026 Nine questions on conditions, switch expressions, loops, arrays and methods. C# C# control flow quiz 9 questions, instant feedback Question 1 of 9 Which condition type does an if statement require? A int B bool C string D Any type C# requires a bool. Unlike C, an int does not convert to bool. Question 2 of 9 What does the null-coalescing operator ?? return? A The left operand if not null, otherwise the right B The right operand always C A boolean D The first non-empty string a ?? b evaluates to a when a is not null, otherwise b. Question 3 of 9 What does a switch expression need to be exhaustive? A A default arm or a throw arm B A break statement C A return type D A goto The compiler requires every path to produce a value, so an arm for the remaining cases or an arm that throws is needed. Question 4 of 9 Which loop checks its condition after the body? A for B while C do-while D foreach do-while runs the body once before testing, which suits prompts that must appear at least once. Question 5 of 9 What is the index range of new int[4]? A 1 to 4 B 0 to 4 C 0 to 3 D 1 to 3 Arrays are zero-indexed, so four elements occupy 0 through 3. Accessing 4 throws IndexOutOfRangeException. Question 6 of 9 Which property gives an array's length? A Count() B Length C Size D Capacity Arrays expose Length. Lists expose Count. Question 7 of 9 What is an expression-bodied method? A A method with no return type B A method written with => instead of braces C A lambda D An abstract method int Square(int x) => x * x; is shorthand for a body with a single return statement. Question 8 of 9 What does a method returning void produce? A null B Nothing C 0 D An error void methods perform an action and return no value, so they cannot be used in an expression. Question 9 of 9 What does the params keyword allow? A Optional parameters B A variable number of arguments C Named arguments D Ref parameters params int[] values lets a caller pass values individually, which the compiler collects into an array. Check my answers Try again Your answers stay in this browser. Nothing is sent to a server. More quizzes C# basics quiz Coming soon C# objects quiz 9 questions C# library quiz 9 questions All quizzes