.Net Technologies Interview Questions and Answers for Freshers


Tips to remember :
  • 1. First of all think about What I Want To Hear If I Ask You To Tell Me About Yourself
  • 2. Start with the present and tell why you are well qualified for the position.
  • 3. Best to start with a strong simple statement about yourself (again related to the job and type of person they are looking for) and expand with a synthesized work history that shows how miraculously every thing you have done up to now has led you to this precise moment and prepared you perfectly for this job!
  • • Array stores the values or elements of same data type but arraylist stores values of different datatypes.
int arr[] = new int[10]
  • • Arrays will use the fixed length but arraylist does not uses fixed length like array.
  • • In Server.Transfer page processing transfers from one page to the other page without making a round-trip back to the client’s browser. This provides a faster response with a little less overhead on the server. The clients url history list or current url Server does not update in case of Server.Transfer.
Server.Transfer("TechTrickNews.aspx");
  • • Response.Redirect is used to redirect the user’s browser to another page or site. It performs trip back to the client where the client’s browser is redirected to the new page. The user’s browser history list is updated to reflect the new address.
Response.Redirect("TechTrickNews.aspx");

A cookie is often used to identify a user. A cookie is a small file that the server embeds on the user's computer. Each time the same computer requests a page with a browser, it will send the cookie too. With ASP, you can both create and retrieve cookie values. The default time for a Cookie to expire is 30 minutes.

Type of Cookies ?
  • 1. Persist Cookie - A cookie has not have expired time Which is called as Persist Cookie
  • 2. Non-Persist Cookie - A cookie has expired time Which is called as Non-Persist Cookie

Here is a some list of properties containing the HttpCookies Class:-

  • 1. Domain: Using these properties we can set the domain of the cookie.
  • 2. Expires: This property sets the Expiration time of the cookies.
  • 3. HasKeys: If the cookies have a subkey then it returns True.
  • 4. Name: Contains the name of the Key.
  • 5. Path: Contains the Virtual Path to be submitted with the Cookies.
  • 6. Secured: If the cookies are to be passed in a secure connection then it only returns True.
  • 7. Value: Contains the value of the cookies.

Union is used to combine all result sets and it removes the duplicate records from the final result set obtained unlike UnionAll which returns all the rows irrespective of whether rows are being duplicated or not.

Note: Union All is more faster than Union.

"Static" keyword can be used for declaring a static member. If the class is made static then all the members of the class are also made static. If the variable is made static then it will have a single instance and the value change is updated in this instance.

Sealed class is used to prevent the class from being inherited from other classes. So "sealed" modifier also can be used with methods to avoid the methods to override in the child classes.

sealed class SealedClass
{
}

Common Language Runtime (CLR) is a managed execution environment that is part of Microsoft’s .NET framework. CLR manages the execution of programs written in different supported languages.

Common Language Runtime (CLR) is a heart of Microsoft’s .NET framework.

CLR transforms source code into a form of bytecode known as Common Intermediate Language (CIL). At run time, CLR handles the execution of the CIL code.

Below are the list of responsibilities of Common Language Runtime –
  • • Garbage Collection
  • • Code Access Security
  • • Code Verification

It executes application-level events and sets application-level variables.

Filters allow us to add pre-action and post-action behaviors from action, for achieving this functionality ASP.NET MVC provides a feature called Filters.

ASP.NET MVC supports following types of filters:

  • 1. Action Filters : Action Filters allow us to add before-action and after-action behavior to controller action methods.
ASP.NET MVC provides the following action filters:
  • Output Cache: This action filter caches the output of a controller action for a specified amount of time.
  • Handle Error: This action filter handles errors raised when a controller action executes.
  • Authorize: This action filter enables you to restrict access to a particular user or role.
  • 2. Authorization Filters :- It is used to implement authorization and authentication for action filters
  • 3. Result Filters :- Performs some operation before or after the execution of view result.
  • 4. Exception Filters :- Performs some operation if there is an unhandled exception thrown during the execution of the ASP.NET MVC pipeline.
ViewData
  • 1. ViewData is used to pass data from controller to view.
  • 2. It is derived from ViewDataDictionary class.
  • 3. It is available for the current request only.
  • 4. Requires typecasting for complex data type and checks for null values to avoid error.
  • 5. If redirection occurs, then its value becomes null.
ViewBag
  • 1. ViewBag is also used to pass data from the controller to the respective view.
  • 2. ViewBag is a dynamic property that takes advantage of the new dynamic features in C# 4.0
  • 3. It is also available for the current request only.
  • 4. If redirection occurs, then its value becomes null.
  • 5. Doesn’t require typecasting for complex data type.
TempData
  • 1. TempData is derived from TempDataDictionary class
  • 2. TempData is used to pass data from the current request to the next request
  • 3. It keeps the information for the time of an HTTP Request. This means only from one page to another. It helps to maintain the data when we move from one controller to another controller or from one action to another action.
  • 4. It requires typecasting for complex data type and checks for null values to avoid error. Generally, it is used to store only one time messages like the error messages and validation messages.

Delete command removes the rows from a table based on the condition that we provide with a WHERE clause. Truncate will actually remove all the rows from a table and there will be no data in the table after we run the truncate command.

TRUNCATE
  • 1. TRUNCATE is faster and uses fewer system and transaction log resources than DELETE.
  • 2. TRUNCATE removes the data by deallocating the data pages used to store the table's data, and only the page deallocations are recorded in the transaction log.
  • 3. TRUNCATE removes all rows from a table, but the table structure, its columns, constraints, indexes and so on, remains. The counter used by an identity for new rows is reset to the seed for the column.
  • 4. You cannot use TRUNCATE TABLE on a table referenced by a FOREIGN KEY constraint. Because TRUNCATE TABLE is not logged, it cannot activate a trigger.
  • 5. TRUNCATE cannot be rolled back.
  • 6. TRUNCATE is DDL(data defination language) Command.
  • 7. TRUNCATE Resets identity of the table(Starting from 1)
DELETE
  • 1. DELETE removes rows one at a time and records an entry in the transaction log for each deleted row.
  • 2. If you want to retain the identity counter, use DELETE instead. If you want to remove table definition and its data, use the DROP TABLE statement.
  • 3. DELETE Can be used with or without a WHERE clause.
  • 4. DELETE Activates Triggers.
  • 5. DELETE can be rolled back.
  • 6. DELETE is DML(data manipulation language) Command.
  • 7. DELETE does not reset identity of the table.

Note: DELETE and TRUNCATE both can be rolled back when surrounded by TRANSACTION if the current session is not closed. If TRUNCATE is written in Query Editor surrounded by TRANSACTION and if session is closed, it can not be rolled back but DELETE can be rolled back.
  • • Temporary Tables are physically created in the tempdb database. These tables act as the normal table and also can have constraints, index like normal tables.\
  • • Table Variable acts like a variable and exists for a particular batch of query execution. It gets dropped once it comes out of batch. It is created in the memory database but may be pushed out to tempdb.
  • • Generics in c# is used to make the code reusable and which intern decreases the code redundancy and increases the performance and type safety.
  • • Namespace – "System.Collections.Generic" is available in C# and this should be used over "System.Collections" types.

jQuery no-conflict is an option given by jQuery to overcome the conflicts between the different js frameworks or libraries. When we use jQuery no-conflict mode, we are replacing the $ to a new variable and assigning to jQuery some other JavaScript libraries. Also use the $ (Which is the default reference of jQuery) as a function or variable name what jQuery has. And in our development life, we are not at all strict to only jQuery.

A Stored Procedure is a collection or a group of T-SQL statements. Stored Procedures are a precompiled set of one or more statements that are stored together in the database. They reduce the network load because of the precompilation. We can create a Stored Procedure using the "Create proc" statement

Area is used to store the details of the modules of our project. This is really helpful for big applications, where controllers, views and models are all in main controller, view and model folders and it is very difficult to manage.

GridView : -
  • • Limited in design, works like an html table. More in built functionality like edit/update, page, sort. Lots of overhead
  • • A GridView displays your data source in an HTML table and extends it to allow paging, sorting, editing etc.
  • • A gridview can only show your data in a table.
  • • Editing of contents is supported.
  • • Built-in Paging and Sorting is provided.
  • • Performance is very slow as compared to Repeater.
Repeater : -
  • • Very light weight. No built in functionality like Headers, Footers. Has the least overhead.
  • • A repeater is a template control, where you specify the html that is used to render each row.
  • • A repeater can show your data in any way you want by creating the relevant ItemTemplate. For example you might show a list of products, with each product having an image, description, list of colours, price etc, all arranged as you'd normal see a product listing. A repeater can supply that kind of display flexibility.
  • • Editing of contents is not supported.
  • • You need to write custom code.
  • • This is very light weight and fast data control among all the data control
  • • In method overriding, we change the method definition in the derived class that changes the method behavior.
  • • Method overloading is creating a method with the same name within the same class having different signatures.

In an ASP.NET web application that does not make use of routing, an incoming browser request should map to a physical file. If the file does not exist, we get page not found error.

An ASP.NET web application that does make use of routing, makes use of URLs that do not have to map to specific files in a Web site. Because the URL does not have to map to a file, you can use URLs that are descriptive of the user's action and therefore are more easily understood by users.

What are the 3 things that are needed to specify a route ?
  • 1. URL Pattern - You can include placeholders in a URL pattern so that variable data can be passed to the request handler without requiring a query string.
  • 2. Handler - The handler can be a physical file such as an .aspx file or a controller class.
  • 3. Name for the Route - Name is optional.

routes.MapRoute(

"View", // Route name

"View/ViewCustomer/{id}", // URL with parameters

new { controller = "Customer", action = "DisplayCustomer",

id = UrlParameter.Optional }); // Parameter defaults

A constructor is a member function with the same name as its class. The constructor is invoked whenever an object of its associated class is created.It is called constructor because it constructs the values of data members of the class.

class Sum
{
int a, b;
public Sum() //default contructor
{
a = 50;
b = 25;
}
}

A view is a virtual table which contains data from one or more tables. Views restrict data access of table by selecting only required values and make complex queries easy. Rows updated or deleted in the view are updated or deleted in the table the view was created with. It should also be noted that as data in the original table changes, so does data in the view, as views are the way to look at part of the original table. The results of using a view are not permanently stored in the database.

  • • "Const" keyword is used for making an entity constant. We cannot modify the value later in the code. Value assigning is mandatory to constant variables. Constant variables are declared and initialized at compile time.
const int RollNo = 11;
  • • "readonly" variable value can be changed during runtime and value to readonly variables can be assigned in the constructor or at the time of declaration.
readonly int RollNo = 11;
Abstract class :-
  • Abstract class can have abstract and non-abstract methods.
  • Abstract class doesn't support multiple inheritance.
  • Abstract class can have final, non-final, static and non-static variables.
  • Abstract class can provide the implementation of interface.
  • The abstract keyword is used to declare abstract class.

The abstract keyword is used to declare abstract class.

Example:
public abstract class Shape
{
public abstract void draw();
}

Interface :-
  • Interface can have only abstract methods. it can have default and static methods also.
  • Interface supports multiple inheritance.
  • Interface has only static and final variables.
  • Interface can't provide the implementation of abstract class.
  • The interface keyword is used to declare interface.
Example:
public interface Drawable
{
void draw();
}

Below are the options in AJAX helpers –

  • Url – This is the request URL.
  • Confirm – This is used to specify the message which is to be displayed in confirm box.
  • OnBegin – Javascript method name to be given here and this will be called before the AJAX request.
  • OnComplete – Javascript method name to be given here and this will be called at the end of AJAX request.
  • OnSuccess - Javascript method name to be given here and this will be called when AJAX request is successful.
  • OnFailure - Javascript method name to be given here and this will be called when AJAX request is failed.
  • UpdateTargetId – Target element which is populated from the action returning HTML.

Below are some of the features supported in C# -

  • • Allows Us to Create Single Page Application
  • • Supports Two Way Data Binding
  • • Cross Browser Compliant
  • • Supports Animation
  • • Its Code are Unit Testable
  • • Follows MVC Pattern
  • • Predefined Form Validations
  • • Open Source

Data Binding is the automatic synchronization of data between model and view. There are two ways of data binding:

  • • One way data binding (used in classical template)
  • • Two way data binding (used in AngularJS template)
  • • MVC
  • • Modules
  • • Validations
  • • Directives
  • • Templates
  • • Scope
  • • Expressions
  • • Data Binding
  • • Filters
  • • Services
  • • Routing
  • • Testing

As a fresher, salary is not the first priority for me. I want to improve my knowledge and skill as well as gain experience. And my salary would be according to company norms and standards.

Popular Posts

Get Latest Stuff Through Email


Stay Connected

Who Should Read TechTrick?

All the tricks and tips that TechTrick provides only for educational purpose. If you choose to use the information in TechTrick to break into computer systems maliciously and without authorization, you are on your own. Neither I (TechTrick Admin) nor anyone else associated with TechTrick shall be liable. We are not responsibe for any issues that caused due to informations provided here. So, Try yourself and see the results. You are not losing anything by trying... We are humans, Mistakes are quite natural. Here on TechTrick also have many mistakes..