DOT NET Developer

500+ DOT NET Developer Interview Questions and Answers

Updated 22 Jan 2025
search-icon

Q1. What is the difference between windows application development and web based development?

Ans.

Windows app dev is for desktops, web dev is for browsers.

  • Windows app dev is for desktop operating systems like Windows, macOS, and Linux.

  • Web dev is for browsers and can be accessed from any device with an internet connection.

  • Windows app dev uses GUI frameworks like Windows Forms or WPF.

  • Web dev uses web technologies like HTML, CSS, and JavaScript.

  • Examples of Windows apps include Microsoft Word and Adobe Photoshop.

  • Examples of web apps include Facebook and Google Maps.

Q2. What is Trigger,Store procedure, join in sql query and their syntax

Ans.

A trigger is a database object that is automatically executed in response to certain events. A stored procedure is a named group of SQL statements that can be executed. A join is used to combine rows from two or more tables based on a related column between them.

  • Triggers are used to enforce business rules, perform data validation, or automate tasks.

  • Stored procedures are used to encapsulate a set of SQL statements for reuse and better performance.

  • Joins are used to retrieve dat...read more

DOT NET Developer Interview Questions and Answers for Freshers

illustration image

Q3. How many ways are there to send data to controller from View?

Ans.

There are multiple ways to send data from View to controller in ASP.NET MVC, including form submission, AJAX calls, query strings, and model binding.

  • Form submission using HTML forms

  • AJAX calls using jQuery or other JavaScript libraries

  • Query strings in the URL

  • Model binding in ASP.NET MVC

Q4. Can Two Primary keys can be made possible in Sql Table ?

Ans.

No, only one primary key can be defined in a SQL table.

  • Primary key ensures uniqueness of each record in a table.

  • A table can have only one primary key constraint.

  • However, a composite primary key can be created using multiple columns.

Are these interview questions helpful?

Q5. What kind of database you used in projects

Ans.

I have experience working with various databases including SQL Server, Oracle, and MySQL.

  • I have worked with SQL Server extensively and have experience in writing complex queries and stored procedures.

  • I have also worked with Oracle and have experience in creating and managing tables, indexes, and views.

  • I have used MySQL for smaller projects and have experience in designing and implementing databases.

  • I am familiar with database design principles and normalization techniques.

  • I h...read more

Q6. What Are JOINS in SQL and difference between Inner JOIN and equi JOIN? Illustrate with an example.

Ans.

JOINS are used in SQL to combine data from two or more tables based on a related column.

  • Inner JOIN returns only the matching rows from both tables

  • Equi JOIN is a type of Inner JOIN where the join condition is based on equality between two columns

  • Example: SELECT * FROM table1 INNER JOIN table2 ON table1.column = table2.column

Share interview questions and help millions of jobseekers 🌟

man-with-laptop

Q7. If you have class and private variable. Can you use that class in other class?

Ans.

Yes, by using access modifiers like public or internal.

  • Yes, by changing the access modifier of the class to public or internal.

  • Private variables can be accessed within the same class but not outside. Use properties or methods to access them in other classes.

  • Example: class A has a private variable 'x'. In class B, create an instance of class A and access 'x' using a public method or property.

Q8. If you have static constructor and default constructor, which gets executed first?

Ans.

Static constructor gets executed first before default constructor.

  • Static constructor is called only once, when the class is first accessed or instantiated.

  • Default constructor is called every time a new instance of the class is created.

  • Example: If a class has both static and default constructors, the static constructor will be executed before the default constructor.

DOT NET Developer Jobs

Dot NET Developer 1-2 years
Robert Bosch Engineering and Business Solutions Private Limited
4.2
Hyderabad / Secunderabad
Dot Net Developer with Azure Cloud 1-2 years
Robert Bosch Engineering and Business Solutions Private Limited
4.2
Hyderabad / Secunderabad
Dot NET Developer with Azure Skills 4-6 years
Capgemini
3.8
₹ 10 L/yr - ₹ 15 L/yr
Hyderabad / Secunderabad

Q9. from sql: temp table vs table variable, write query to sum +ve and -ve no in separate column from java script: == vs ===

Ans.

Comparison of temp table and table variable in SQL and difference between == and === in JavaScript.

  • Temp tables are stored in tempdb and table variables are stored in memory.

  • Temp tables can be indexed and used in joins, while table variables cannot.

  • == compares values while === compares values and data types in JavaScript.

Q10. what is filter? How to add custom filter? How to configure middleware?

Ans.

Filters are used to manipulate incoming and outgoing requests. Custom filters can be added and middleware can be configured to handle them.

  • Filters are used to modify or validate incoming and outgoing requests in ASP.NET Core.

  • Custom filters can be added by creating a class that implements IFilterMetadata interface.

  • Middleware can be configured to handle filters using the UseFilter extension method.

  • Filters can be used for authentication, caching, logging, and more.

  • Filters can be...read more

Q11. What is oops? Oops is a object oriented programing system

Ans.

Object-oriented programming (OOP) is a programming paradigm that uses objects to represent and manipulate data.

  • OOP focuses on creating reusable code by organizing data and behavior into objects.

  • It emphasizes concepts like encapsulation, inheritance, and polymorphism.

  • Objects have attributes (data) and methods (functions) that can interact with each other.

  • Example: In C#, classes are used to define objects and their properties and methods.

Q12. what is the components of dotnetframework which types

Ans.

The components of .NET Framework include Common Language Runtime, Class Library, and ASP.NET.

  • Common Language Runtime (CLR) - manages memory, security, and execution of code

  • Class Library - provides a set of reusable classes and types for building applications

  • ASP.NET - a web application framework for building dynamic web pages and web services

  • Other components include ADO.NET, Windows Communication Foundation (WCF), Windows Presentation Foundation (WPF), and Windows Workflow Fou...read more

Q13. In your Project, How did you connected your application with Database?

Ans.

I used Entity Framework to connect the application with the database.

  • Utilized Entity Framework for ORM mapping

  • Configured connection string in the application's configuration file

  • Used LINQ queries to interact with the database

Q14. Select ID,Name from Employee where Salary = { Selelct Max(Salary) from Employee};

Ans.

The query selects the ID and Name of the employee with the highest salary.

  • The query uses a subquery to find the maximum salary in the Employee table.

  • The outer query then selects the ID and Name of the employee with that maximum salary.

Q15. String vs String Builder. Comparision of their mutability, speed, memory allocated, usability. Was provided a use case and asked which one to use and how. String Interpolation. String Manipulation.

Ans.

String is immutable, while StringBuilder is mutable. StringBuilder is faster and more memory efficient for string manipulation.

  • String is immutable, meaning once created, it cannot be changed. StringBuilder is mutable, allowing for efficient string manipulation.

  • StringBuilder is faster than String for concatenating multiple strings, as it does not create a new string object each time.

  • String uses more memory as it creates a new object every time it is modified, while StringBuild...read more

Q16. What is difference between Abstract Class and Interface?

Ans.

Abstract class can have implementation details while interface cannot. Class can implement multiple interfaces but only inherit from one abstract class.

  • Abstract class can have method implementations while interface cannot.

  • A class can implement multiple interfaces but can only inherit from one abstract class.

  • Interfaces are used to define a contract for classes to implement, while abstract classes are used to provide a common base for subclasses.

  • Abstract classes can have constr...read more

Q17. Class A { } ClassB:A { } Static void Main() { A obj1 = new A(); A obj2 = new B(); B obj3 = new B(); B obj4 = new A();

Ans.

The code snippet demonstrates object instantiation and inheritance in C#.

  • Class B inherits from Class A.

  • Objects of Class A and Class B can be instantiated.

  • An object of a derived class can be assigned to a base class reference variable.

Q18. What is the Difference between Abstract and Interface? What is Sealed Class? Explain About non-generic class. What is managing and unmanaging?

Ans.

Abstract classes can have both abstract and non-abstract methods, while interfaces can only have abstract methods. Sealed classes cannot be inherited. Non-generic classes do not have type parameters.

  • Abstract classes can have method implementations, while interfaces cannot.

  • Interfaces can be implemented by multiple classes, but a class can only inherit from one abstract class.

  • Sealed classes cannot be inherited by other classes.

  • Non-generic classes do not have type parameters, un...read more

Q19. Abstract class vs interfaces. What would i choose and why.

Ans.

Abstract class is used when there is a need for default implementation, while interfaces are used for multiple inheritance.

  • Abstract classes can have both abstract and non-abstract methods, while interfaces can only have abstract methods.

  • Abstract classes can provide default implementations for methods, while interfaces cannot.

  • Interfaces allow a class to implement multiple interfaces, but can only inherit from one abstract class.

  • Use abstract classes when there is a need for a c...read more

Q20. Pipelines and Middlewares in .NET. How would i configure them.

Ans.

Pipelines and Middlewares in .NET are used for request processing and can be configured using middleware components.

  • Pipelines in .NET are used to define a series of middleware components that process an HTTP request.

  • Middlewares are components that can handle requests and responses in the pipeline.

  • To configure pipelines and middlewares in .NET, you can use the 'UseMiddleware' method in the 'Configure' method of the Startup class.

  • You can also use extension methods like 'UseRout...read more

Q21. What is Encapsulation? How do you hide data using Encapsulation?

Ans.

Encapsulation is the concept of bundling data and methods that operate on the data within a single unit.

  • Encapsulation helps in hiding the internal state of an object and restricting access to it.

  • Data hiding is achieved by making the variables private and providing public methods to access or modify them.

  • For example, a class 'Car' may have private variables like 'model' and 'year' with public methods like 'getModel()' and 'setYear()' to access or modify them.

Q22. What happens, if we have same methods in two interface?

Ans.

Conflict arises and implementing class must explicitly implement the method from both interfaces.

  • Conflict arises when implementing class implements both interfaces

  • Implementing class must explicitly implement the method from both interfaces

  • Example: Interface A and Interface B both have a method named 'foo', implementing class must provide implementation for 'foo' from both interfaces

Q23. What is dependency injection? How to implement it? What is tightly coupled? What is loosely coupled?

Ans.

Dependency injection is a design pattern where the dependencies of an object are provided externally rather than created within the object itself.

  • Dependency injection helps in achieving loosely coupled code by allowing objects to be easily replaced or modified without changing the core logic.

  • It involves injecting dependencies into a class through constructor injection, setter injection, or interface injection.

  • Tightly coupled code refers to classes or components that are highl...read more

Q24. What is Primary key? Can it be null? Can we have multiple primary key?

Ans.

Primary key uniquely identifies each record in a table. It cannot be null and there can be only one primary key.

  • Primary key ensures each record in a table is unique

  • Primary key cannot have null values

  • Only one primary key can be defined for a table

  • Primary key can be a single column or a combination of columns

Q25. Coding Question: Variable 1 = 10; Variable 2 = 20; Variable 3 = 0; Variable 3 = Variable 1 * Variable 2; Do Calculation without using Multiplication

Ans.

Use bitwise operations to perform multiplication without using the * operator.

  • Use bitwise left shift operator to multiply Variable 1 by 2^n where n is the value of Variable 2.

  • Add the result of each left shift operation to get the final result.

Q26. What are HTML helpers? Can we create custom HTML Helpers?

Ans.

HTML helpers are methods that help in rendering HTML in a view. Yes, we can create custom HTML helpers.

  • HTML helpers are methods that generate HTML markup in a view.

  • They help in reducing the amount of HTML code that needs to be written in a view.

  • Custom HTML helpers can be created by defining extension methods on the HtmlHelper class.

  • Custom HTML helpers can be useful for generating reusable HTML components or complex HTML markup.

  • Example: Creating a custom HTML helper to generat...read more

Q27. What is Sql joins, cte, Sp vs function, user defined types,

Ans.

SQL joins are used to combine rows from two or more tables based on a related column between them.

  • SQL joins are used to retrieve data from multiple tables based on a related column.

  • Common types of joins include INNER JOIN, LEFT JOIN, RIGHT JOIN, and FULL JOIN.

  • CTE (Common Table Expression) is a temporary result set that can be referenced within a SELECT, INSERT, UPDATE, or DELETE statement.

  • Stored Procedures (SP) are precompiled SQL statements that are stored in the database an...read more

Q28. Can we write multiple stored procedures Inside Stored Procedures? Can we write functions inside stored procedures?

Ans.

Yes, we can write multiple stored procedures inside stored procedures. Functions can also be written inside stored procedures.

  • Yes, you can call one stored procedure from another stored procedure.

  • You can also define and call functions inside a stored procedure.

  • Example: CREATE PROCEDURE spOuter AS BEGIN CREATE PROCEDURE spInner AS ... END; END;

  • Example: CREATE PROCEDURE spOuter AS BEGIN CREATE FUNCTION fnInner() RETURNS ... AS ... END; END;

Q29. What is globalization? How to support multiple languages in application?

Ans.

Globalization is the process of designing and developing applications that can be used in multiple languages and cultures.

  • Use resource files to store text in different languages

  • Use Unicode encoding to support different character sets

  • Use culture-specific formatting for dates, times, and numbers

  • Test the application with different languages and cultures to ensure proper functionality

Q30. How database is connected in current project and Can we update multiple databse using DbSet?

Ans.

Database is connected using Entity Framework in current project. Yes, we can update multiple databases using DbSet.

  • Database is connected using Entity Framework which provides a data access layer for interacting with the database.

  • DbSet is a collection of entities that can be queried, updated, inserted, and deleted in the database.

  • By using DbSet, we can update multiple databases by specifying the database context for each operation.

  • Example: dbContext1.Set().Add(entity); dbConte...read more

Q31. How do you follow OOPS concepts and other best practices in your project?

Ans.

I follow OOPS concepts by using inheritance, encapsulation, polymorphism, and abstraction in my code.

  • I use classes and objects to encapsulate data and behavior.

  • I utilize inheritance to create a hierarchy of classes with shared attributes and methods.

  • I implement polymorphism by overriding methods in derived classes.

  • I apply abstraction to hide complex implementation details from the user.

Q32. Difference between Stored procedure and functions when we use where we use what the profits of its?

Ans.

Stored procedures are precompiled SQL queries stored in the database, while functions are user-defined routines that return a value.

  • Stored procedures are used for performing specific tasks or operations on the database, while functions are used to return a single value.

  • Stored procedures can contain multiple SQL statements and can have input and output parameters, while functions are more limited in their functionality.

  • Stored procedures are generally used for complex business ...read more

Q33. Static void main{ int val =5; show(val); Console.WriteLine("Value of val is "+val); } Internal class show(int i) { i*=i; Console.WriteLine("Value of i is"+i); }

Ans.

The code snippet demonstrates a simple program in C# that declares a variable, calls a method to square its value, and then prints the updated value.

  • The 'show' method takes an integer parameter and squares its value before printing it.

  • The 'val' variable is passed to the 'show' method, which updates its value to 25.

  • The final output will display the updated value of 'val' as 25.

Q34. Divide the array in two Halves and keep each half in ascending order without using new Array?

Ans.

Divide array in two halves and keep each half in ascending order without using new Array.

  • Use Array.sort() method to sort the original array

  • Use Array.slice() method to divide the array into two halves

  • Use Array.reverse() method to reverse the second half of the array

Q35. Prepare an example of JWT authentication and Oauth for an API.

Ans.

JWT authentication and OAuth example for API

  • Implement JWT authentication by generating a token upon user login and including it in the Authorization header of API requests

  • Use OAuth for user authorization by obtaining access tokens from a third-party provider like Google or Facebook

  • Ensure API endpoints validate JWT tokens and OAuth access tokens before allowing access to resources

Q36. Can static constructor have multiple arguments?

Ans.

No, static constructors cannot have multiple arguments.

  • Static constructors in C# do not take any arguments.

  • They are used to initialize static data members or perform any necessary setup for the class.

  • Example: public static MyClass() { // constructor code }

Q37. How to integrate third party web api in our project

Ans.

Integrating third party web APIs involves obtaining API key, making HTTP requests, parsing responses, and handling errors.

  • Obtain API key from third party provider

  • Make HTTP requests to the API endpoints

  • Parse the JSON/XML response data

  • Handle errors and exceptions gracefully

Q38. What are Interfaces and Why do we need interfaces?

Ans.

Interfaces are contracts that define a set of methods and properties that a class must implement.

  • Interfaces provide a way to achieve abstraction and polymorphism in object-oriented programming.

  • They allow for loose coupling between classes and promote code reusability.

  • Interfaces can be used to define common behavior across multiple classes.

  • Example: IDisposable interface in C# ensures that an object can be properly disposed of when it is no longer needed.

  • Example: IComparable in...read more

Q39. Stored procedure. String vs String builder, Triggers and how it helps. How to improve query performance. Indexes, types and uses. Validations. Common Table Expression.

Ans.

Stored procedures, string vs string builder, triggers, query performance, indexes, validations, and common table expressions in DOT NET development.

  • Stored procedures are precompiled SQL queries stored in the database for reuse and performance optimization.

  • String builder is more efficient for concatenating large strings compared to regular string concatenation.

  • Triggers are database objects that automatically perform actions when certain events occur in the database.

  • Query perfo...read more

Q40. Tell Travelling Salesman Problem Optimal Solution Approach

Ans.

The optimal solution approach for the Travelling Salesman Problem involves using algorithms such as the Nearest Neighbor Algorithm and the 2-Opt Algorithm.

  • The Nearest Neighbor Algorithm starts at a random city and selects the nearest unvisited city as the next stop.

  • The 2-Opt Algorithm involves swapping two edges in the tour to see if it results in a shorter distance.

  • Other algorithms include the Genetic Algorithm and the Simulated Annealing Algorithm.

  • The optimal solution is no...read more

Q41. What is Compile time binding and Runtime Binding?

Ans.

Compile time binding occurs during compilation while runtime binding occurs during execution.

  • Compile time binding is also known as early binding, where the method to be called is determined at compile time based on the type of the object.

  • Runtime binding is also known as late binding, where the method to be called is determined at runtime based on the actual type of the object.

  • Compile time binding is faster as it is done during compilation, while runtime binding is slower as i...read more

Q42. How to change layout page during runtime?

Ans.

You can change the layout page during runtime by dynamically setting the layout property in the code behind.

  • Set the layout property in the code behind based on certain conditions or user input.

  • Use conditional statements to determine which layout page to use.

  • Example: if(userRole == 'admin') { Layout = '~/Views/Shared/_AdminLayout.cshtml'; } else { Layout = '~/Views/Shared/_UserLayout.cshtml'; }

Q43. What is Clustered and Non clustered Index?

Ans.

Clustered index physically reorders the data in the table while non-clustered index creates a separate structure.

  • Clustered index determines the physical order of data rows in a table.

  • Non-clustered index creates a separate structure to store the index data.

  • A table can have only one clustered index but multiple non-clustered indexes.

  • Clustered index is faster for retrieval but slower for insert and update operations.

  • Non-clustered index is slower for retrieval but faster for inse...read more

Q44. What is difference between Delete and Truncate?

Ans.

Delete removes rows one by one and can be rolled back, while Truncate removes all rows at once and cannot be rolled back.

  • Delete is a DML command while Truncate is a DDL command.

  • Delete can be rolled back using a transaction, while Truncate cannot be rolled back.

  • Delete fires triggers on each row deletion, while Truncate does not fire triggers.

  • Delete is slower as it removes rows one by one, while Truncate is faster as it removes all rows at once.

  • Delete maintains the identity of ...read more

Q45. What is Inheritance and Types of Inheritance?

Ans.

Inheritance is a mechanism in OOP where a class inherits properties and behaviors from another class.

  • Inheritance allows a class to reuse code from another class.

  • Types of inheritance include single inheritance, multiple inheritance, multilevel inheritance, hierarchical inheritance, and hybrid inheritance.

  • Example: Class B inheriting from Class A - B is a subclass of A.

Q46. What is method overloading and method overriding?

Ans.

Method overloading is when multiple methods have the same name but different parameters. Method overriding is when a subclass provides a specific implementation of a method that is already provided by its parent class.

  • Method overloading allows a class to have multiple methods with the same name but different parameters.

  • Method overriding occurs in a subclass when a method has the same name and parameters as a method in its superclass.

  • Method overloading is resolved at compile t...read more

Frequently asked in,

Q47. Query to find 4th higesty salary

Ans.

Query to find 4th highest salary

  • Use the 'ROW_NUMBER' function to assign a rank to each salary

  • Order the salaries in descending order

  • Select the salary with rank 4

Q48. What are the SQL queries to delete and update records based on specific conditions?

Ans.

SQL queries for deleting and updating records based on specific conditions

  • For deleting records based on specific conditions: DELETE FROM table_name WHERE condition;

  • For updating records based on specific conditions: UPDATE table_name SET column1 = value1, column2 = value2 WHERE condition;

Q49. What are the uses of the SELECT, DELETE, and UPDATE queries in SQL?

Ans.

SELECT is used to retrieve data, DELETE is used to remove data, and UPDATE is used to modify data in SQL.

  • SELECT is used to retrieve specific data from a database table.

  • DELETE is used to remove specific data from a database table.

  • UPDATE is used to modify existing data in a database table.

  • Examples: SELECT * FROM table_name, DELETE FROM table_name WHERE condition, UPDATE table_name SET column_name = value WHERE condition

Q50. What are ViewBag, ViewData, and TempData in ASP.NET, and what are the differences between them?

Ans.

ViewBag, ViewData, and TempData are ways to pass data between controllers and views in ASP.NET.

  • ViewBag is a dynamic property that allows you to pass data from the controller to the view. It uses dynamic typing.

  • ViewData is a dictionary object that allows you to pass data from the controller to the view. It requires typecasting.

  • TempData is a dictionary object that allows you to pass data from one controller to another or from one action to another.

  • ViewBag and ViewData are used ...read more

1
2
3
4
5
6
7
Next
Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories

Interview experiences of popular companies

3.7
 • 10.3k Interviews
3.9
 • 8.1k Interviews
3.7
 • 7.6k Interviews
3.7
 • 5.6k Interviews
3.8
 • 5.5k Interviews
3.8
 • 4.8k Interviews
3.5
 • 3.8k Interviews
3.8
 • 3k Interviews
3.8
 • 2.8k Interviews
3.3
 • 165 Interviews
View all

Calculate your in-hand salary

Confused about how your in-hand salary is calculated? Enter your annual salary (CTC) and get your in-hand salary

DOT NET Developer Interview Questions
Share an Interview
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions
Get AmbitionBox app

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter