C# Mastery Hub
Home
Challenges
Discussion
Lessons
Core Topics
C# Fundamentals
Console Applications
Classes & OOP
Windows Forms
ASP.NET Core
SQL Server
VS & SQL Connection
RDLC Reports
.NET MAUI
Getting Started
Getting Started
Website Development
SEO Guide
Security
Project Workflow
Extra Topics
Cloud & Deployment
AWS Cloud
Deployment
About
Contact
Test Your Knowledge
Classes & OOP Quiz
Answer all questions to test your understanding
1
What is a class in C#?
A blueprint or template for creating objects
A variable that stores data
A method that performs calculations
A type of loop
2
What is an object in C#?
A class that contains methods
An instance of a class
A type of variable
A method that returns a value
3
Which keyword is used to create an object in C#?
create
new
object
instance
4
What is a field in a C# class?
A method that returns data
A variable declared inside a class
A property that validates data
A constructor that initializes data
5
What is the purpose of a property in C#?
To store data without validation
To provide controlled access to fields with get and set accessors
To create methods that return data
To define the constructor of a class
6
What is an auto-implemented property in C#?
A property that requires manual backing field implementation
A property where the compiler automatically generates the backing field
A property that cannot be modified
A property that only has a getter
7
What does the 'init' accessor do in a property?
Allows the property to be set only during object initialization
Makes the property read-only
Makes the property write-only
Allows the property to be set at any time
8
What is a method in C#?
A block of code that performs a specific task
A variable that stores data
A type of class
A property that validates data
9
What is method overloading in C#?
Having multiple methods with the same name but different parameters
Having methods with different names
Having methods in different classes
Having methods that return different types
10
What is the purpose of the 'params' keyword in C#?
To define a parameter as optional
To allow a method to accept a variable number of arguments
To make a parameter read-only
To pass parameters by reference
11
What is a constructor in C#?
A method that is called when an object is created
A method that is called when an object is destroyed
A property that initializes data
A field that stores data
12
What is constructor chaining in C#?
Calling multiple constructors in sequence
One constructor calling another constructor in the same class using : this()
Creating multiple objects with the same constructor
Inheriting constructors from a base class
13
What is encapsulation in C#?
Hiding internal data and exposing only what's needed
Creating multiple methods with the same name
Inheriting from a base class
Sharing data between classes
14
Which access modifier makes a member accessible only within the same class?
public
private
protected
internal
15
What is the purpose of the 'protected' access modifier?
Allows access only within the same class
Allows access within the same class and derived classes
Allows access anywhere in the same assembly
Allows access from anywhere
16
What is inheritance in C#?
A class inheriting properties and methods from another class
A class inheriting from multiple classes
A class inheriting from an interface
A method inheriting from another method
17
Which keyword is used to call a base class constructor in C#?
base
this
super
parent
18
What is the purpose of the 'sealed' keyword in C#?
To prevent a class from being inherited
To prevent a method from being overridden
To make a class abstract
To make a method virtual
19
What is polymorphism in C#?
The ability to have many forms
The ability to have many classes
The ability to have many methods
The ability to have many objects
20
What is the difference between 'virtual' and 'override' in C#?
'virtual' allows a method to be overridden, 'override' replaces the method implementation
'virtual' replaces the method, 'override' allows a method to be overridden
They are the same thing
'virtual' is used for properties, 'override' is used for methods
21
What is an abstract class in C#?
A class that cannot be instantiated and can contain abstract methods
A class that can only be inherited
A class that contains only static methods
A class that cannot be inherited
22
What is an interface in C#?
A contract that defines methods without implementation
A class that contains implementation
A type of abstract class
A method that can be overridden
23
What is the main difference between an abstract class and an interface?
Abstract classes can have implementation, interfaces cannot (before C# 8)
Abstract classes cannot be inherited, interfaces can
Interfaces can have fields, abstract classes cannot
There is no difference
24
What is the difference between static and instance members in C#?
Static members belong to the class, instance members belong to objects
Static members belong to objects, instance members belong to the class
They are the same thing
Static members can only be used in static classes
25
When should you use static methods?
When the method doesn't need access to instance data
When the method needs access to instance data
When you want to create multiple instances
When you want to override the method
26
What are generics in C#?
A way to define classes and methods with type parameters
A way to create objects without types
A type of collection
A way to avoid type safety
27
What is the purpose of generic constraints in C#?
To restrict the types that can be used as type arguments
To make generics faster
To allow any type to be used
To create multiple instances
28
What does the 'S' in SOLID stand for?
Single Responsibility Principle
Simple Responsibility Principle
Static Responsibility Principle
System Responsibility Principle
29
What does the 'O' in SOLID stand for?
Open/Closed Principle
Object-Oriented Principle
Overriding Principle
Optimization Principle
30
What does the 'L' in SOLID stand for?
Liskov Substitution Principle
Linear Substitution Principle
Logical Substitution Principle
Language Substitution Principle
31
What does the 'I' in SOLID stand for?
Interface Segregation Principle
Interface Substitution Principle
Implementation Segregation Principle
Inheritance Segregation Principle
32
What does the 'D' in SOLID stand for?
Dependency Inversion Principle
Dependency Integration Principle
Direct Inversion Principle
Data Inversion Principle
Submit Quiz