Hi, developers! Today I am going to cover mostly asked interview questions for Dot Net Developer. As I have personally being interviewed by these questions as a Dot Net Developer in top IT companies like Tata Consultancy Services (TCS), Infosys, Genpact, Wipro, Nagarro, Secure Meters Ltd., Swaran Soft Support Solutions Private Limited, FIS Global.
If you are preparing for an interview as Dot Net Developer and having 0-3 years of experience, I would highly recommend you to be prepared for these important questions before the interview.
I have answered these questions as I have answered in front of Interviewers.
ASP.NET MVC Interview Questions:
What is MVC Framework?
MVC is a framework which uses for building web applications whether it is dynamic or static. MVC stands for Model View Controller, Modal behaves as a business layer, View is presentation layer used for UI logic of the web application and Controller does the interaction between Model and View components to process all the business logic and incoming requests.
What are the sessions in MVC?
We can use three different types of the sessions in MVC.
- ViewBag: It can be used to pass the data from controller to view. It is a dynamic property and doesn’t require typecasting.
- ViewData: It can be used to pass the data from controller to view and it requires typecasting for complex data type and checks for null values to avoid errors.
- TempData: It can pass the data from controller to view as well as from one controller to another controller too. It has features to keep() and ToPeek to holds the data for a period of time of an HTTP request. It also requires typecasting as ViewData.
What are the Action Filters in MVC?
Action filter runs before and after the execution of Action method. There are mainly 5 types of action filters in ASP.NET MVC. It executes as I sequenced below.
What is Routing?
Routing plays the main part in the MVC framework. It is nothing but an URL pattern. It has 3 important segments of routing. ControllerName, ActionMethodName and Parameter (It can be optional).
Lifecycle of MVC?
Request Context Created
Controller Instance Created
What is Partial View?
A partial view is a portion of HTML that can be injected within a view. It does not have its own layout and doesn’t contain any markup.
What are the different return types in MVC?
There is the different return type of controller action methods in MVC like ViewResult, ActionResult, FileResult, ContentResult, JsonResult, RedirectResult, etc.
How to enable Attribute routing?
We have to call the MapMvcAttributeRoutes method of route collection class during the configuration.
OOPs Concept (C#) Interview Questions:
Pillars of OOPs concept?
There are 4 important pillars of OOPs. Abstraction, Encapsulation, Inheritance and Polymorphism.
What are the Sealed, Static, Abstract and Interface in C#?
Sealed Class: Sealed classes cannot be inherited. The sealed keyword is used to create a sealed class to restrict access to users to inherit that class.
Abstract Class: If we don’t want a class to be instantiated, we should define the class as abstract using the abstract keyword. An abstract class can have both abstract and non-abstract methods. If a method is defined as abstract, it must be implemented in a derived class.
Static Class: If the value of an attribute had to be same across all the instances of the same class, we should use the “static” keyword to create the static class. We cannot create the instance of a static class. We cannot use “this” keyword with a static class.
Interface: Interfaces have only declarations, not the implementation. Its members are public by default. They don’t allow explicit access modifiers. If a class or struct inherits from an interface, it must provide implementations for all interface members. When we want to use the multiple inheritance in C# then we use the interface.
What is Polymorphism?
Polymorphism enables us to invoke derived class methods using a base class reference variables at runtime it’s called Polymorphism.
What is overloading and overriding?
Overloading: Method overloading has same name but different signature. It is also known as compile time polymorphism.
Overriding: Method overriding has the same name and same signature. It can be achieved by the “virtual” keyword in base class and will use the “override” keyword to override the methods to the derived class.
What is Virtual keyword?
When we want to give permission to a derived class to override a method in base class, virtual keyword can be used.
What are the access modifiers in C#?
Public: It can be accessed anywhere and there are no restrictions.
Private: It can be accessible within the containing types.
Protected: It can be accessible within the containing types and type derived from containing type.
Internal: It can be accessed anywhere within the containing assembly.
Protected Internal: It can be accessible within the containing assembly and from within a derived class in another assembly.
Which method is used to call garbage collector?
We use System.GC.Collect() method to call the garbage collector.
What is String and StringBuilder?
String: String is the immutable type where it means we cannot change the value of a string variable once it declared.
StringBuilder: StringBuilder is the mutable type where it means we can change the value at runtime. We perform the update, append or remove operations using StringBuilder.
What is the difference between “==” and “===”?
Operator (==): It compares the value of variables.
Operator (===): It compares the values as well as data type also.
What is constant in C#?
We can use the Const keyword to declare the constant field across, once a variable has been declared const, its value cannot be changed across the program. A constant is a number, string, null reference, or Boolean value.
SQL Server Interview Questions:
What are Indexes?
Index is used by the server to improve the speed of the retrieval of rows by using a pointer. There are two types of Indexes.
Clustered Index: It must be satisfied two conditions. First, the data or file that you are moving into secondary memory should be sorted or sequential order the second condition is data should be unique i.e., non-key value. We can create only one clustered index in a table like a primary key. If you have one clustered index on multiple columns then this type of index is called composite index.
Non-Clustered Index: In a non-clustered index, the data is stored in one place and the index is stored in another place. You can have multiple non-clustered indexes in one table.
Write a query to get nth highest salary in SQL?
Using Common Table Expressions, we can write a query to get nth salary in SQL.
With RESULT as
(SELECT Salary, DENSE_RANK() over (Order By Salary Desc) as DENSERANK from Employee)
SELECT Top 1 Salary FROM RESULT
Where RESULT.DENSERANK = Nth
What is difference between function and Stored procedure?
Functions: Function must return value. It will allow only SELECT statements and do not allow us to use DML statements. It supports only input parameters, not the output. Transactions are not allowed within the functions. We cannot call stored procedures from a function.
Stored Procedure: Stored procedure may or not return value. It will allow SELECT statements and as well DML statements. It supports both input and output parameters. Transactions are allowed within the Stored procedure. We cannot call functions from a stored procedure.
- As I was asked to write code, syntax, real time example at the time of interviews too. So, I would highly suggest to you all please be prepared well before the interviews.
- These collections of questions are for 0-3 years of experienced developers.
- Questions may be different or vary and depend on interviewers.
- Also, learn about EntityFramework and LINQ queries.
I would also suggest you to go thru the below topics for differences between type questions
- Difference between ASP and ASP.NET
- Difference between Partial View and View
- Difference between Abstract and Interface
- Difference between Abstraction and Encapsulation
- Difference between Drop, Truncate, and Delete command
- Difference between Struct and Class
- Difference between Dense_Rank and Row_Number
- Difference between varchar and nvarchar
- Difference between First() and FirstOrDefault
- Difference between ViewBag and TempData
- Difference between Authorization and Authentication
- Difference between Verification and Validation
- Difference between Html.Partial() and Html.RenderPartial()
- Difference between Order By and Group By
- Difference between Boxing and Unboxing
- Difference between Value type and Reference type
Hope I have covered mostly asked interview questions for a Dot Net Developer. The questions depend on the interviewer, so, I would suggest you be prepared very well before the interview with extra interview questions. These questions are generally for Fresher to 3 years of experience developers.
Please comment if you have been asked for any additional questions and answers.
All the best for your next interviews…!!!
Happy Coding 😊!