.Net Questions/Answers

Q1: what are access modifiers?
A:  1. Public
Public means visible to everyone and everywhere.
2.Private
Private means hidden and usable only by the class itself. No code using a class instance can access a private member and neither can a derived class. Information or functionality that will not be needed or has no meaning outside of the context of a specific class should be made private.
3.Protected
Protected members are similar to private ones in that they are accessible only by the containing class. However, protected members also may be used by a descendant class. So members that are likely to be needed by a descendant class should be marked protected.
4. Internal
Internal are public to the entire assembly but private to any outside assemblies. Internal is useful when you don’t want to allow other assemblies to have the functionality.
5. Protected internal
Finally, we have the only compound access modifier allowed in .NET. Members marked as protected internal may be accessed only by a descendant class that’s contained in the same assembly as its base class. You use protected internal in situations where you want to deny access to parts of a class’ functionality to any descendant classes found in other applications.
Q2: which one is default access modifier? 
Ans : Public.
Q3: 4 pillars of OOPS?
Ans: Abstraction, encapsulation, inheritance and polymorphism.
Q4: Explain the steps to create and implement Satellite Assemblies.
Ans: Satellite assemblies are resource assemblies specific to language/culture. Different resource files are created for different languages/cultures and then the needed one is loaded based on the user.
1. Create a new web application
2. Drag 2 label controls, a dropdownlist and a button control. Add 2 items to the drop down, en-US and fr-FR.
3. Add a new folder called resources and add 2 resource assembly files in it., e.g.: res1.resx and res1.fr-FR.resx In res1.resx, add a key “Welcome” and value as “Hello there”. In res1.fr-FR.resx, add a key called “Welcome” and value as “Bon Journe”.
4. Generate their resource files by using the resgen command for each of these resource files and keep them in the App_GlobalResources folder.
5. On button’s click even at the following code:
6. Session["language"]=dropdownlist1.SelectedItem .Text ;
Response.Redirect (“Webform2.aspx”);
7. Add a label inWebform2.aspx. In page load event of Webform2.aspx.cs add the following code.
System.Resources.ResourceManager resourceManager
=ResourceManager.CreateFileBasedResourceManager(“res1″,Server.MapPath(“Resources”)+Path.DirectorySeparatorChar , null);
string getLanguage = Session["language"].ToString ();
CultureInfo cultureInfo=new CultureInfo(getLanguage);
Label1.Text=resourceManager.GetString (“Welcome”,cultureInfo);
When you execute the Webform1.aspx, choose one of the English or French option from the dropdownlist and hit the button. It should display welcome message based on the chosen option from the dropdownlist.
Q5: command line syntax in C#
Ans: csc classname.cs
Q6: what does assemby contains..?
Ans: It contains information about metadata and manifest.
Q7: Keywords to pass a varable by reference in C#?
Ans: By using ref.
SQL Server
Q1: Types of joins
Ans: Inner, left outer, right outer, full outer, self and equi join
Q2: which one is fast? truncate or delete? why?
Ans: DELETE logs the data for each row affected by the statement in the transaction log and physically removes the row from the file, one row at a time. The recording of each affected row can cause your transaction log grow massively if you are deleting huge numbers of rows. However, when you run your databases in full recovery mode, detailed logging is necessary for SQL Server to be able to recover the database to the most recent state, should a problem arise. The fact that each row is logged explains why DELETE statements can be slow.
TRUNCATE is faster than DELETE due to the way TRUNCATE “removes” rows. Actually, TRUNCATE does not remove data, but rather deallocates whole data pages and removes pointers to indexes. The data still exists until it is overwritten or the database is shrunk. This action does not require a lot of resources and is therefore very fast. It is a common mistake to think that TRUNCATE is not logged. This is wrong. The deallocation of the data pages is recorded in the log file.
ASP.net
Q1: How to create a master page?
Ans: Right-click in the solution explorer and select Add New Item. Select Master Page from the template and provide a name for the page. In this example I am using myMaster.master (where .master is the extension of the file). Click Add.
This will add the .master file to the project. This is our master page.
A Master Page can contain the same Web controls, User controls, HTML content, and scripts that can be added to a standard ASP.NET page. There are three important differences between a Master Page and a normal ASP.NET page.
First, unlike a normal ASP.NET page, the name of a Master Page must end with the special extension .master. This extension marks the page as a Master Page. Furthermore, an ASP.NET application is configured so that you cannot request pages with the .master extension.
Second, a Master Page includes a <%@ Master %> directive instead of the normal <%@ Page %> directive. The <%@ Master %> directive supports many of the same attributes as the <%@ Page %> directive. For example, you can specify the programming language of the page with the directive <%@ Master Language=”vb” %>.
The final difference between a Master Page and a normal ASP.NET page is that a Master Page can contain zero or more ContentPlaceHolder controls. A ContentPlaceHolder control can be used only within a Master Page. This control marks an area of a Master Page that can be overridden by a particular content page.
Q2: Page life cycle?
Ans: The Life Cycle of a page when requested for the first time:
Initializing: During this phase, the server creates an instance of the server control
Loading: During this phase, the instance of the control is loaded onto the page object in which it is defined.
PreRendering: During this phase, the control is updated with the changes made to it. This prepares the control for rendering.
Saving: During this phase, the state information of the control is saved. For example, if a value is set for the control during the Load event, it is embedded in the HTML tag that will be returned to the browser.
Rendering: During this phase, the server creates the corresponding HTML tag for the control.
Disposing: During this phase, all cleanup tasks, such as closing files and database connections opened by the control are performed.
Unloading: During this phase, all cleanup tasks, such as destroying the instances of server control are performed. This is the final event in the life cycle of a server control
Q3: Exception thrown in response.redirect?
Ans: The Response.Redirect always generates an Exception “Thread was being
aborted.”

Comments

Popular posts from this blog

Specify port number in ASP.NET Development Server

Server Variables in .Net Web Application

Free Windows Azure Exam