Unlock hundreds more features
Save your Quiz to the Dashboard
View and Export Results
Use AI to Create Quizzes and Analyse Results

Sign inSign in with Facebook
Sign inSign in with Google

Master Your C# Skills with This Free Assessment Test

Think you can ace this C# programming test? Start your free C# online test today!

Difficulty: Moderate
2-5mins
Learning OutcomesCheat Sheet
Paper art illustration for C assessment test quiz on a dark blue background.

This C# assessment quiz helps you practice core syntax, OOP basics, and problem solving so you can spot gaps before an interview or exam. Start the full run in the main assessment , or try a short warm-up first. Questions include quick code checks and concept questions from beginner to advanced.

Which keyword is used to define a constant field in C#?
static
readonly
const
fixed
Use the const keyword to define a constant whose value is set at compile time and cannot be changed. Constants declared with const are implicitly static and cannot be modified after compilation. The readonly modifier, in contrast, allows assignment at runtime in a constructor. See .
What is the default value of a bool type field in C#?
true
false
null
0
Fields of value types in C# are initialized to their default values; for bool this default is false. Local variables are not automatically initialized, but fields and array elements are. This ensures predictable behavior when fields are accessed before explicit assignment. See .
Which of these is a reference type in C#?
float
string
char
int
In C#, string is a reference type, while int, float, and char are value types. Reference types store a reference to the actual data on the managed heap. Value types directly contain their data and are usually allocated on the stack. See .
Which loop construct guarantees that the loop body executes at least once?
while
do-while
foreach
for
A do-while loop executes its body first and then evaluates the condition, ensuring at least one execution. In contrast, for, while, and foreach evaluate their conditions before the first execution. This makes do-while suitable when the loop body must run at least once. See .
How do you declare a namespace in C#?
using MyName { }
pack MyName { }
namespace MyName { }
module MyName { }
Namespaces in C# are declared using the namespace keyword followed by the namespace name and braces. They organize classes and other types and help avoid naming collisions. The using directive is separate and allows shorter type references. See .
What operator provides a default value if the operand is null?
||
?
?:
??
The null-coalescing operator ?? returns the left operand if it's not null; otherwise it returns the right operand. It simplifies checking for null and providing default values. The conditional operator ?: is different and requires a boolean test. See .
How do you denote a single-line comment in C#?
/* comment */
#comment
// comment
-- comment
Single-line comments in C# begin with // and continue to the end of the line. Block comments use /* and */. The # symbol is used for preprocessor directives, not comments. See .
What is the correct signature for the entry point of a C# console application?
void Main()
static int Main()
public Main(string[] args)
static void Main(string[] args)
The entry point for a C# console app is a static Main method. It can return void or int and may take a string[] of arguments. The most common signature is static void Main(string[] args). Access modifiers like public are optional at the top level. See .
What is the output of the following code? int x = 5; Console.WriteLine(x++);
6
0
Compile error
5
The postfix increment operator x++ returns the original value before incrementing. Therefore Console.WriteLine(x++) prints 5, then x becomes 6 afterward. A compile error does not occur because x++ is valid on an int. See .
Which exception is specifically thrown when an integer division by zero occurs?
NullReferenceException
ArithmeticException
DivideByZeroException
IndexOutOfRangeException
Dividing an integral type by zero throws a DivideByZeroException in .NET. ArithmeticException is the base class but not thrown directly for integer zero division. Floating-point division by zero yields Infinity or NaN instead of an exception. See .
What does LINQ stand for?
Linked IN Queue
Language INtegrated Query
List IN Query
Language Indexed Query
LINQ stands for Language Integrated Query and allows querying collections using a SQL-like syntax in C#. LINQ expressions are translated into method calls or expression trees. It supports various providers like LINQ to Objects, LINQ to SQL, and more. See .
Which generic collection automatically grows and maintains the order of insertion?
List
Dictionary
HashSet
Queue
List is a dynamic array that grows as elements are added and preserves insertion order. Dictionary stores key/value pairs without guaranteed order. HashSet is an unordered set. Queue is a FIFO structure but not typically used for random access. See .
Which delegate declaration correctly defines a method signature that returns void and takes an int parameter?
delegate int MyDel();
delegate int MyDel(int x);
delegate void MyDel();
delegate void MyDel(int x);
Delegates in C# declare method signatures; the syntax delegate void MyDel(int x); defines a method that returns void and takes an int parameter. Changing the return type or removing parameters alters the signature. Delegates are type-safe method pointers. See .
How do you subscribe to an event named 'Changed' using a handler 'OnChanged'?
obj.Changed = += OnChanged;
obj.Add(OnChanged);
obj.Changed = OnChanged;
obj.Changed += OnChanged;
In C#, you subscribe to events by using the += operator to add a delegate. obj.Changed += OnChanged; registers OnChanged as a handler. Using = would overwrite all existing handlers. See .
What is method overloading in C#?
Same method name with different parameter lists
Using virtual methods
Same method signature in derived class
Overriding a method in base class
Method overloading is defining multiple methods with the same name but different parameter types or counts within the same class. The overloads must differ by signature. This differs from overriding, which replaces a base class virtual method. See .
Which symbol is used in C# to inherit from a base class or implement an interface?
.
:
->
#
In C#, the colon (:) specifies inheritance or interface implementation, as in class Derive : Base or class C : IInterface. The dot (.) accesses members, and other symbols are not used for inheritance. See .
What is the purpose of the async keyword when applied to a method?
Marks the method as asynchronous, enabling await usage inside it
Indicates the method returns a Task without configuration
Runs the method on a new thread automatically
Executes the method synchronously
The async modifier enables the await operator inside a method and transforms its return type into Task or Task. It does not automatically create new threads, but allows asynchronous operations without blocking. The compiler generates a state machine to handle continuations. See .
Which class in .NET is used to create and manage threads?
System.Threading.Thread
System.Threading.Timer
System.Threading.Tasks.Task
System.Thread.Manager
The System.Threading.Thread class represents an OS thread and allows explicit creation and control of threads. Task is a higher-level abstraction built on threads from the ThreadPool. Timer schedules callbacks but is not for general threading. See .
In multithreading, what is the purpose of the lock statement?
Prevents deadlocks automatically
Ensures that only one thread can access a resource at a time
Schedules threads in the thread pool
Locks the application until all threads complete
The lock statement acquires the mutual-exclusion lock for a given object, preventing other threads from entering the locked block until it's released. It helps synchronize access to shared resources and avoid race conditions. It does not schedule threads or automatically prevent all deadlocks. See .
How do you start a Task that executes a method 'DoWork'?
Task.Start(DoWork);
Task.Run(() => DoWork());
new Task(DoWork);
DoWork().Task();
Task.Run schedules the delegate on the ThreadPool and starts it immediately. new Task(DoWork) only creates a Task instance; you must call Start() to run it. Task.Start(DoWork) is invalid syntax. See .
Which namespace contains reflection types such as Type and PropertyInfo?
System.Reflection
System.Runtime
System.Reflection.Emit
System.Linq
Reflection types like Type, PropertyInfo, and MethodInfo are defined in System.Reflection. System.Reflection.Emit provides classes for building dynamic assemblies. System.Runtime and System.Linq serve other purposes. See .
What does the unsafe keyword allow in C#?
Run without garbage collection
Use of pointer types and direct memory manipulation
Bypass JIT compilation
Execute code without type checking
The unsafe context enables pointer types and operations similar to C/C++ pointer arithmetic. It allows direct memory access but requires the /unsafe compiler option. It does not disable garbage collection or type checking elsewhere. See .
Which cast would unbox an object 'obj' to an int?
Convert.ToInt32(obj)
(int)obj
obj as int
int.Parse(obj)
Unboxing converts an object containing a boxed value type back to that value type using a direct cast like (int)obj. The as operator cannot cast to value types. Convert.ToInt32(obj) boxes/unboxes indirectly and may incur overhead. See .
What is boxing in C#?
Converting a value type to object or interface type
Compiling code to MSIL
Encrypting data in memory
Encapsulating exceptions
Boxing is the process of converting a value type to a reference type (object or interface). The runtime allocates an object on the heap and copies the value. Unboxing is the reverse. Excessive boxing/unboxing can impact performance. See .
What is an expression tree in C# primarily used for?
Optimizing LINQ queries at compile time
Representing code as a data structure that can be inspected or modified at runtime
Generating random expressions dynamically
Compiling code to native machine instructions
Expression trees represent code in a tree-like data structure, allowing dynamic inspection, modification, or compilation at runtime. They are heavily used in LINQ providers to translate queries into other forms (e.g., SQL). They differ from delegates by preserving structure rather than only behavior. See .
0
{"name":"Which keyword is used to define a constant field in C#?", "url":"https://www.quiz-maker.com/QPREVIEW","txt":"Which keyword is used to define a constant field in C#?, What is the default value of a bool type field in C#?, Which of these is a reference type in C#?","img":"https://www.quiz-maker.com/3012/images/ogquiz.png"}

Study Outcomes

  1. Understand C# Fundamentals -

    Master core syntax, data types, and control structures to build a solid foundation for your C# programming test.

  2. Apply Object-Oriented Programming Concepts -

    Utilize classes, inheritance, and interfaces to solve real-world coding scenarios in this C# online test.

  3. Implement Advanced C# Features -

    Explore LINQ, async/await, and delegates to enhance your solutions and demonstrate proficiency in the C# quiz.

  4. Analyze and Debug Code Efficiently -

    Identify common errors and optimize performance by working through practical debugging challenges in the c sharp quiz.

  5. Evaluate Your C# Skill Level -

    Leverage instant feedback from the C# assessment test to pinpoint strengths and areas for improvement.

  6. Track Progress and Boost Confidence -

    Monitor your scores over time and refine your coding techniques to advance from beginner to expert in C# programming.

Cheat Sheet

  1. CLR Data Types: Value vs Reference -

    The Common Language Runtime (CLR) categorizes data into value types and reference types (Microsoft Docs). Value types like int and struct store data directly, while reference types like string and class store a pointer to heap memory. Remember: "Value lives where it is defined, Reference points afar" as a mnemonic.

  2. Control Flow & Exception Handling -

    Master if/else, switch, loops and the try/catch/finally pattern as outlined in the official C# specification. Use the switch expression in C# 8+ for concise matching, for example: result = day switch { Day.Monday => "Start", _ => "Other" };. As recommended by Microsoft Docs, always catch specific exceptions before general ones to maintain clarity.

  3. OOP Foundations: Classes, Interfaces & Polymorphism -

    Understand classes, structs, inheritance, interfaces and polymorphism according to the .NET documentation. Remember the PIE mnemonic - Polymorphism, Inheritance, Encapsulation - to organize key concepts. For example, override a virtual method in a derived class using public override void Method() to implement runtime polymorphism.

  4. LINQ & Lambda Expressions -

    Leverage Language-Integrated Query (LINQ) to query collections declaratively, as shown in MSDN guides. Example: var evens = numbers.Where(n => n % 2 == 0).ToList(); uses a lambda for filtering. Practice both query syntax and method syntax to maximize readability and performance.

  5. Async/Await & Task-based Programming -

    Write non-blocking code using the async and await keywords per .NET official docs. For instance, async Task<int> FetchDataAsync() returns a Task that you await with var data = await FetchDataAsync();. Familiarize yourself with ConfigureAwait(false) to avoid deadlocks in UI or server applications.

Powered by: Quiz Maker