Thursday, February 26, 2026

.NET & Azure Interview Questions

 

 

2025

 

 G.R.Reddy Technologies      

 

.NET & AZURE

 

 

 

[.NET & AZURE Interview Questions]

.Net & Azure routine interview questions and answers.

 


 




Tell me about yourself:

Hi this is Ravinder Reddy, having 4+Years of IT experience on Microsoft technologies like C#, ASP.NET MVC, Web API with .net core, Entity Framework, SQL Server and Azure PAAS Services. I have experience in different domains like Asset Management, Retail, education and insurance. ORMs like Entity Framework, dapper and ADO.NET. Databases like SQL Server and MongoDB.

Coming to my current project is LSAC,

Law School Administrative Council. It’s an education domain.

Functionality: It maintains the student information like student personal data, course details, fees details and marks details. Law school is a university having around 2000 branches in U.S.A and 5-6 users from each college.

Technicall: We have followed API based architecture, front end Angular, back end API with .Net core and database is SQL server. So, we got split into 3 different teams

a) UI development

b) API development

c) Database

I am from the API development and azure platform maintenance team.

My day-to-day activities are implementing API endpoints and writing Unit test cases. Apart from this involving in code peer reviews.  We are following agile methodology with two weeks sprint.

What is Oops (Object Oriented Programming)?

OOPS is nothing but Object Oriented Programming System. Mainly four pillars are there.
1) Abstraction
2) Encapsulation
3) Polymorphism
4) Inheritance

1) Inheritance:

Inheritance is nothing but getting the features from one class to another class (parent class to child class).

 Inheritance is 5 types:

1) Single
3) Multiple

3) Multi level
4) Hybrid
5) Hierarchical

Multiple – A child class having more than one parent class,
   it is not possible using classes because of ambiguity problem but it can be implemented by using Interfaces.

Syntax

public class ChildClassName : I1, I2

What is Ambiguity problem and how it is fixed.
If a child class inherits from multiple parent classes that have methods with the same name, it causes confusion for the child class about which parent method to inherit. This situation is known as the ambiguity problem.

This ambiguity can be resolved using interfaces. When a class implements multiple interfaces that have methods with the same name, the child class can provide separate implementations by prefixing the method with the interface name.

Like:

Public class ChildClass

{

Public void I1.Print(){ }

Public void I2.Print(){ }

}

2) Polymorphism

One resource acting as many forms like method overloading and method overriding.

Polymorphism is two types:

1) Method Overloading (Compile time Polymorphism or Static Polymorphism)
2) Method Overriding   (Run time Polymorphism or Dynamic Polymorphism)

Method Overloading is nothing but method name will be same but

either number of parameters

                  or

 types of the parameters

                  or

 order of the parameters

will be different. It can be done in a single class.

 

Even it can be implemented in two classes (parent and child) but not suggestible.

 

Method Overriding is nothing but method name is same and also parameters and everything will be same. It can be implemented in two different classes. The parent class declared as virtual key word and in child class declares with override keyword.

What happens if the parent class method is declared as virtual, but the child class does not use the override keyword?

Don’t get any error but compiler gives warning and suggesting to use the new keyword if hides intentionally.

Answer:

If the parent class declares a method as virtual and the child class defines a method with the same name and signature without using the override keyword, then the child method hides the parent method instead of overriding it.

This is called method hiding, not overriding.

·        If you call the method using a child class reference, the child method is executed.

·        If you call it using a parent class reference, the parent method is executed, because polymorphism does not work without override.

C# will give a compiler warning, suggesting you to use the new keyword to indicate that you are hiding the method intentionally.

What happens if the parent class method is not declared as virtual, but the child class tries to use the override keyword?

The compiler will throw an error.

This is because:

·        The override keyword in C# is only valid for overriding a method that is marked as virtual, abstract, or override in the base class.

·        If the base method is not marked appropriately, there is nothing to override, so the compiler does not allow it.

What happens if the parent class method is not declared as virtual, but the child class tries to use the new keyword?

Don’t get any error

3) Encapsulation

Binding the related data as one unit like a class.

                                       OR

Binding related data(information) and methods(actions) into one unit like a class — so they work together as a single item.

How Encapsulation is Achieved in C#:

1.  Declare fields as private ex: private string name;

public string name {get{return name};set{name=value};}

2.     Provide access via public properties or methods

Here:

·        The name field is encapsulated.

·        Outside classes can’t access name directly.

·        They must use the Name property, which can include validation or logic.

 

4) Abstraction

hiding the implementation and giving the functionality to the end user.
                                           OR

hiding the data (implementation) and giving the functionality to the end user.

                                             OR

Hiding complex implementation details and show only the essential features of an object.

In C#, abstraction can be achieved in two main ways:

1.     Abstract classes

2.    Interfaces

What is class?

Class is a logical representative that defines properties and behaviors.

                                                 OR

Class is a logical representative or template that defines the structure and behavior (like data and methods) of objects. It does not occupy memory by itself.

What is object?

Object is a physical representative, memory-allocated when instance created for a class.

                                                 OR

An object is a physical representative of a class. It is created in memory and represents a real entity based on the class definition.

What is constructor?

Constructor is a special method.

It is used to initialize the class variables.

It doesn’t have the return type.

Constructor name should be same as class name.

Constructor will be called automatically when we create object for that class.

Types of constructors:

a)    Default Constructor / Parameter less Constructor

b)   Parameterized Constructor

c)    Static Constructor

d)   Private Constructor

e)    Copy Constructor

f)     Clone Constructor

Which constructor will be called first if we create an object for a child class?

Topmost parent class constructor will be called first then second topmost parent class constructor then finally last child class (i.e object created class) constructor will be called.

Example:

Class A is a parent class and Class B is a child class. Class A constructor will be called first then class B constructor will be called when we create an object for class B.

What is Access Modifier and types?

Access modifiers are restricting the access level in our application, it helps to implement encapsulation. They are essential for code security, maintenance.

Total 6 access modifiers are there:

private  : accessible within the same class only

public   : accessible anywhere in the application.

internal : accessible within same assembly only.

protected: accessible within the same class as well as derived class    

                     (Irrespective of assembly).

protected internal : within the same assembly anywhere it may be   

                                     derived class or not (or) within derived class outside  

                                     of the assembly also.

private protected  : within assembly (and) within derived class only.

Default Access modifiers for class, method, fields and properties.

Default Access Modifier class is internal

Default Access Modifier method is public

Default Access Modifier fields or properties is private

Default Access Modifier Interface is Public

Stack Memory Vs Heap Memory:

Stack memory: Stores short-lived, local variables and method information while the code is running (runtime). stores value types in stack memory, Faster access.

Heap memory: Stores objects and data that need to exist beyond method calls while the code is running (runtime). Stores reference types in heap memory, Slower access.

Boxing and Unboxing:

Boxing: Converting value type to reference type is called boxing.

Ex: int data type to object.

Unboxing: Converting reference type to value type is called unboxing.

Ex: object data type to int.

Different Types of the classes:

1.    Concrete Class

2.    Abstract Class

3.    Static Class

4.    Sealed Class

5.    Partial Class

6.    Nested Class

7.    Generic Class

8.    Interface

Class Type

Can Instantiate?

Can Inherit?

Special Use

Concrete

Yes

Yes

Regular class

Abstract

No

Yes

Base class, abstract methods

Sealed

Yes

No

Prevent inheritance

Static

No

No

Only static members, helper methods

Partial

Yes

Yes

Split class into multiple files

Nested

Yes

Yes

Organize code within another class

Generic

Yes

Yes

Work with any data type using type parameters type parameters

 

 

 

Difference between constant and readonly?

Constant: Constant is a constant the value cannot be changed.

This value is set at compile time and cannot be changed.

 

Readonly: Readonly is also a constant but we can change the value at constructor level.

This value is set at runtime (in constructor or declaration) and cannot be changed after that.

difference between ref and out?

Both ref and out are very similar—when we change the parameter inside the method, the original variable outside the method also changes.

ref should be initialized before passing it whereas out is not required.

But while returning out should be initialized and ref is not required.

Out return multiple values from a method.

Difference between abstract class and interface?

Interface: it contains set of rules that is incomplete methods; those should be implemented in direct derived class or indirect derived class.

a)    It Support Multiple Inheritance

b)   Enable Loose Coupling

c)    Support Dependency Injection and Unit Testing

d)   Achieve Abstraction(Interfaces allow us to define what a class should do, but not how it should do it).

Abstract class: If a class has minimum one abstract method then we can declare that class as abstract class. Abstract class can contain both abstract methods and concrete methods.

Abstract class cannot be instantiated directly. It can include fields, constructors and access modifiers.

 

Among the all derived classes having some common functionalities then we can use abstract class otherwise we can use interface and if we want implement multiple inheritance then we can use interfaces.

 

 

Difference between string and stringbuilder?

what is method hiding ?

 

How do you prevent a class from being inherited?

Sealed class.

How do you prevent a class from being instantiated ?

 

Difference between Task.Run and async/await:

🔹 Task.Run:

Purpose: Moves the work to a separate background thread so it doesn't slow down the main program. This is helpful when doing heavy tasks that take time, like complex calculations.

Use case: For CPU-bound operations that need to run in parallel to avoid blocking the main thread.

Not needed for I/O-bound tasks (like DB calls, file I/O, HTTP), which already support true async.

 

🔹 async/await:

  Purpose: execute the program asynchronously, and await will pause the method execution until get the response from the called method but not block the worker thread from thread pool.(that means thread will be free and will be used to do other tasks…. Like it will be used for new request coming from outside).

  Use case: For I/O-bound operations(like DB calls, file I/O, HTTP) to improve scalability by not blocking threads.

Benefit: Higher scalability without needing more threads.

 

The ThreadPool is designed to scale smartly — grow under load

Growth continues until:

·        The max limit is hit (e.g., 32,767 in .NET Core by default)

NET keeps them alive — but only for a while.

1.     Idle threads are not destroyed immediately.

Eventually, threads are retired (released)

o   If a thread remains idle for a certain amount of time (usually minutes),

o   .NET will let it die (cleanup), and reduce the pool size.

This is called "thread retirement".

What is .ConfigureAwait(false):

.ConfigureAwait(false) tells the runtime:

It tells the application to don’t bock the main thread. (UI or context thread).
"After the await, we do not need to continue on the original context—just use any available thread from thread pool."

It Avoid Deadlocks and Performance Improvement.

IQueryable vs IEnumerable:

IQueryable executed at

 

Explain SOLID principles.

1. Single Responsibility Principle (SRP):

A class should have only one reason to change, meaning it should have only one responsibility.

2. Open/Closed Principle (OCP):

Application should be open for extension but closed for modification.

3. Liskov Substitution Principle (LSP):

Child classes should be substitutable for their base classes without altering the correctness of the program.

4. Interface Segregation Principle (ISP):

Instead of maintaining single interface for all methods, it should be segregated based on the modules or functionality.

5. Dependency Inversion Principle (DIP):

High-level modules should not depend on low-level modules. Both should depend on abstractions. Abstractions should not depend on details. Details should depend on abstractions.

 

4) What is Liskov Substitution Principle with one real time example?

 

 

Real Time issues which you faced during your experience:

v Performance Issues:

In my project each and every endpoint should give the response within 2 seconds. If any endpoint takes more than 2 seconds, testing team will send it back to developers to improve the performance.

We optimized two sides, application side and database side.

 

APPLICATION SIDE:

1) Asynchronous Programming using async & await for asynchronous

     execution.

2) Pagination for Large Result Sets: should not return thousands of

      records in a single API call.

2) Caching: frequently used data should be caching.

3) API response Compression: larger responses data should be

                                                              Compressed.

4) Minimize Middleware and Filters: should avoid heavy logic in  

     global filters and middleware. Only use essential middleware.

5) Use No-Tracking for Read-Only Queries: For read-only scenarios, we should use .AsNoTracking() in EntityFramework Core to avoid unnecessary change tracking. It doesn’t track the changes like recent updates.

6) Use CDN: “A CDN Content Delivery Network, is a network of globally distributed servers that deliver static content to users from the server closest to their location.

Static files like product images, profile photos, or downloadable files.

 

DATABASE SIDE:

1) Run the Execution Plans: by using SQL Server Management Studio (SSMS) to view execution plans and identify where it is taking more time based on % then we try to optimize in particular areas.

2) Avoid SELECT * from table : Always specify only required columns instead of using SELECT * from table.

3) we should avoid Cursors if Possible: try to use set-based operations (using joins, UPDATE, INSERT, DELETE on sets).

4) Use EXISTS Instead of COUNT(*)>1: If we want to check for existence, use EXISTS as it stops at the first match only, whereas COUNT(*) scans all records.

5)we should use Proper Indexes: make sure the columns used in WHERE, JOIN, and ORDER BY clauses are properly indexed. Avoid unnecessary indexes, as they slow down INSERT, UPDATE, and DELETE.

 6) Use “SET NOCOUNT ON”: we should add “SET NOCOUNT ON” at the beginning of the procedure to avoid sending unnecessary how many rows affected messages.

7) Avoid Unnecessary Computations in Queries: we should do calculations in application code if possible, or use computed columns/indexes.

 

*“To optimize stored procedures, I use proper indexing, avoid SELECT * , and write set-based queries instead of cursors or loops. I always use parameters to support plan reuse and reduce SQL injection risk. I check query execution plans in SSMS to identify bottlenecks and add ‘SET NOCOUNT ON’ to reduce unnecessary network traffic. In my last project, these techniques helped cut down the average query execution time from 2 seconds to under 300 milliseconds.”

 

v API Contract Mismatches:

  Problem:

Frontend-backend mismatches in data models or API contracts it leads to runtime errors.

  Real Example:
In some cases Frontend team expected a “status” field as a string, but backend sent it as an integer. This caused data binding issues and broken UI. We started using Swagger to keep both teams aligned and automated contract testing and also well documented the API’s.

 

v We faced Nuget Package dependency and Versioning Conflicts issues.

  Problem:

When integrating multiple NuGet packages, sometimes I face assembly binding issues and version conflicts, especially during upgrades.

  Real Example:
I once upgraded a project from .NET Framework 4.6 to .NET Core 3.1, and several third-party libraries did not have .NET Core support.  We faced runtime errors due to missing dependencies and we find alternatives and port some packages.

 

v Environment Mismatch:

  Problem:

Code works fine in local & dev environments but fails in production due to differences in environment variables, connection strings, or configurations.

  Real Example:
A production deployment started failing because the Azure Key Vault reference was misconfigured in the appsettings.json file. This caused the app to crash at startup. We implemented stricter configuration validation and a health check endpoint to catch such issues early.

 

                         SQL SERVER:

1) What is an Index in SQL?

     Index is a database object used to make the search faster on a table. It works like the index of a book. We have two types of indexes, clustered index and non-clustered index.

Clustered Index: arrange the data physically so we can create only one on a table. Primary key creates clustered index automatically.

Non-Clustered Index: arrange the data virtually so we can create more than one on a table(total 999). Unique key creates clustered index automatically.

·  Without an index: The database performs a full table scan for queries, which is slow for large tables.

·  With an index: The database uses the index to quickly locate the desired rows, improving performance for SELECT, WHERE, JOIN, and ORDER BY operations.

2) Difference between primary key and unique key:

      Primary key and Unique key both are avoid the duplicate values and 

      null values but unique key allows one null value.

      Primary key automatically creates the clustered index where as

      Unique key creates the non-clustered index.

      We can create only one primary key on a table and more than one 

      Unique keys.

No comments: