dot net interview questions-9

.NET Interview Questions -9
1.What’s the difference between Response.Write() andResponse.Output.Write()?

The latter one allows you to write formattedoutput.

2.What methods are fired during the page load?

Init() - when the page is instantiated, Load() - when the page is loaded into server memory,PreRender()
- the brief moment before the page is displayed to the user asHTML, Unload()
- when page finishes loading.

3.Where does the Web page belong in the .NET Framework class hierarchy?

System.Web.UI.Page

4.Where do you store the information about the user’s locale?

System.Web.UI.Page.Culture

5.What’s the difference between Codebehind="MyCode.aspx.cs" andSrc="MyCode.aspx.cs"?

CodeBehind is relevant to Visual Studio.NET only.

6.What’s a bubbled event?

When you have a complex control, likeDataGrid,writing an event processing routine for each object (cell, button,row, etc.)
is quite tedious. The controls can bubble up their eventhandlers, allowing the main DataGrid event handler to take care of itsconstituents.
Suppose you want a certain ASP.NET function executed on MouseOver overa certain button. Where do you add an event handler? It’s the Attributesproperty,
the Add function inside that property. So btnSubmit.Attributes.Add("onMouseOver","someClientCode();")A simple”Javascript:ClientCode();” in the button control of the .aspx
page will attach the handler (javascript function)to the onmouseover event.

7.What data type does the RangeValidator control support?

Integer,Stringand Date.

8.Where would you use an iHTTPModule, and what are the limitations of any approach you might take in implementing one?

One of ASP.NET’s most usefulfeatures is the extensibility of the HTTP pipeline, the path that data takes between client and server.You can use them to extend your ASP.NET applications by adding pre- and post-processing
to each HTTP request coming into your application. For example, if you wanted custom authentication facilities for your application, the best techniquewould be to intercept the request when it comes in and process the request
in a custom HTTP module.

9.Explain what a diffgram is, and a good use for one?

A DiffGram is an XML format that is used to identify current and original versions of data elements. The DataSet uses the DiffGram format to load and persist its contents,
and to serialize its contents for transport across a network connection. When a DataSet is written as a DiffGram, it populates the DiffGram with all the
necessary information to accurately recreate the contents, though not the schema, of the DataSet, including column values from both the Original and
Current row versions, row error information, and row order.

10.when should you use Abstract Class vs Interface while programming?

When we want that sub class must implement all the methods of base class. In such a situation we will implement the interface. In the other hand when we want only some method of base class in our sub class then use base class as abstract class.

11.What is the difference between application exception and system exception?

The difference between application exception and system exception is that system exceptions are thrown by CLR and application exceptions are thrown by applications.

12.What is the difference between authorization and authentication?

Authorization is a process of allowing or denying resources to particular user or record

Declaration of authorization is

<authorization>
<allow users=”Suresh, Sanjay”/>
<deny users=”Ramana, Rakesh”>
</authorization>
Sometimes authorization allows the unauthorized persons at that time we will use
<deny users=”?”/>

Authentication means Authentication is a process where we identify the credentials of user i.e. username, password and create an identity to mention user as an authenticated. 

13.What is the use of n-tier architecture and 3-tier architecture?

Check this article for 3-tier architecture 3 tier architecture example in asp.net

14.How to get the version of the assembly?

lbltxt.text=Assembly. GetExecutingAssembly().GetName().Version.ToString();

15.What is the location of Global Assembly Cache on the system?

c:\Windows\assembly

16.What is the serialization?

Serialization is a process of converting object into a stream of bites.

17.What is synchronization?

The mechanism needed to block one thread access to the data. If the data is being accessed by another thread.Synchronization can be accessed by using system.monitor class
A monitor class methods are enter, exit, pulse for this lock statement is also used Suppose if we need to synchronize some data at that time we need to place that data in this block
Lock
{
}
Whatever the data has been placed into the lock block that data has been blocked

18.What are the thread priority levels?

Thread priority levels are five types
         0 - Zero level
         1 - Below Normal
         2 - Normal
         3 - Above Normal
         4 - Highest
By Default priority level is 2

19.What is the difference between .tostring(), Convert.tostring()?

The basic difference between them is “Convert” function handles NULLS while
“.ToString()” does not it will throw a NULL reference exception error. So as a good coding practice using “convert” is always safe.

20.What is Collation?

Collation refers to a set of rules that determine how the data is sorted and compared.

21.What is the difference between Primary key and unique key?

Primary key does not allow the null values but unique key allows one null value.Primary key will create clustered index on column but unique key will create non-clustered index by default.

22.How many web.config files are there in 1 project?

There might be multiple web.config files for a single project depending on the hierarchy of folders inside the root folder of the project, so for each folder we can use one web.config file

23.What is the difference between view state and hidden field?

viewstate is secured hidden field is insecure Viewstate will store large amount of data but hidden filed will store small amount of data.

24.What is the Difference between read only and constant variables?

Read only can assign the values at runtime only.Constant will assign the values at compile time only.We cannot modify the both variable values.

25.What is static keyword in .Net?

Static is same as constant variable but we can change the value of static variable and we can access the variables without creating any instances

26.What is difference between constants, read-only and, static?

Constants: The value can’t be changed
Read-only: The value will be initialized only once from the constructor of the class.
Static: Value can be initialized once.

27.What are differences between Array list and Hash table?

1) Hash table store data as name, value pair. While in array only value is store.
2) To access value from hash table, you need to pass name. While in array, to access value, you need to pass index number.
3) you can store different type of data in hash table, say int, string etc. while in array you can store only similar type of data.

28.What are differences between system.stringbuilder and system.string?

The main difference is system.string is immutable and system.stringbuilder is a mutable. Append keyword is used in string builder but not in system.string.
Immutable means once we created we cannot modified. Suppose if we want give new value to old value simply it will discarded the old value and it will create new instance in memory to hold the new value.

29.What are the differences between Application object and session object?

The session object is used to maintain the session of each user. If one user enter in to the application then they get session id if he leaves from the application then the session id is deleted. If they again enter in to the application they get different session id.
But for application object the id is maintained for whole application.

30.What are the different types of indexes?

Two types of indexes are there one is clustered index and non-clustered index

31.How many types of memories are there in .net?

Two types of memories are there in .net stack memory and heap memory

32.Is it possible to set the session out time manually?

Yes we can set the session out time manually in web.config.

33.What are differences between function and stored procedure?

1) Function returns only one value but procedure returns one or more than one value.
2) Function can be utilized in select statements but that is not possible in procedure.
3) Procedure can have an input and output parameters but function has only input parameters only.
4) Exceptions can be handled by try catch block in procedures but that is not possible in function.

34.What are the differences between Abstract and interface?

1) Abstract cannot be instantiated but we can inherit. Interface it cannot be inherit it can be instantiate
2) Interface contain only declarations no definitions. Abstract contain declarations and definitions.
3) The class which contains only abstract methods is interface class. A class which contains abstract method is called abstract class
4) Public is default access specifier for interface we don’t have a chance to declare other specifiers. In abstract we have chance to declare with any access specifier

35.What is the difference between primary key and unique key with not null?

There is no difference between primary key and unique key with not null.

36.What is boxing and unboxing concepts in .net?

Boxing is a process of converting value type into reference type
Unboxing is a process of converting reference type to value type.

37.What are the differences between value type and reference type?

Value type contain variable and reference type are not containing value directly in its memory.
Memory is allocated in managed heap in reference type and in value type memory allocated in stack. Reference type ex-class value type-struct, enumeration

38.Is it possible to host the website from desktop?

Yes

39.Why we go for page rendering in Asp.Net Page life cycle?

Browser understands an only html control that’s why in page rendering we will convert the aspx controls into html controls.

40.Write a sample query for self join?

Select e1.ename, e2.empid from emp e1, emp e2 where e1.empid=e2.mgrid;

41.Can we change the index of primary key on table?

No

42.How to change the name of the table or stored procedure in sql?

sp_rename oldtablename newtablename
For changing the column name
Sp_rename  ‘tablename.[Oldcolumnname]’,’newcolumnname’,’Column’
Ex:sp_rename ‘tblemp.first’,’namechange’,’Column’

43.How to find out which index is defined on table?

sp_helpindex tablename

44.Can you write the program to find the length of string without using library function?

for (int i=0; str[i]!=”\n”; i++)
{
Count++;
}

45.What is the difference between scope_identity() and current_identity()?

Scope_identity and current _identity both are similar and it will return the last identity value generated in the table.
Scope_Identity will return the identity value in table that is currently in scope

46.What do you mean by  ASP?

ASP Stands for Active Server Pages (ASP), which is also  known as Classic ASP, is  Microsoft's server-side technology, which helps in creating  the dynamic and user-friendly Web pages. It uses different scripting languages to create dynamic Web pages, which can be run on any type of  the browser. .

47.What is ASP.NET Explain?

ASP.NET is a specification developed by Microsoft to create  the dynamic Web applications, Web sites, and Web ervices. It is a part of  the .NET Framework. You can create ASP.NET applications in most of the .NET compatible languages, such as Visual Basic, C#, and J#.

48.49.What is  basic difference between ASP and ASP.NET?

The basic difference between  the ASP and ASP.NET is that ASP is interpreted; whereas, ASP.NET is compiled. This implies that since ASP uses VBScript; therefore, when an ASP page is executed, it is interpreted. whereas , ASP.NET uses .NET languages, such as C# and VB.NET, which are compiled to Microsoft Intermediate Language (MSIL).

50.In which event are the controls are fully loaded?

Page load event

51.How can we identify whether  Page is Post Back?

Page object has an  property called as "IsPostBack" property, which can be checked to know that the page posted back.

52.What is the lifespan for items stored in  the ViewState?

The items stored in ViewState live until the lifetime of the current page expires including postbacks to  same page.

53.How users locale  information  can be accessed?

The user's locale information can be accessed by using  System.Web.UI.Page.Culture property.

54.Which is the parent class of  Web server control?

The System.Web.Ul.Control class

55.Can you set which type of comparison you want to perform by  CompareValidator control yes or no?

Yes, by setting the Operator property of the CompareValidator control.

56. What is the sequence in which ASP.NET events are processed?     

    Page_Init
    Page Load
    Control Events
    Page-Unload Events

57. What is a postback? and when is it used in ASP.NET Web forms?
     
A postback is the name for the page request that an ASP.NET page sends to itself when a Web control is activated, such as when users click a button. Most Web forms use the HTML form control, which allows users to submit data using HTTP Post requests.

58. Which method do you use to redirect the user to another page without performing a round trip to the client?
     
Server.transfer()

59. What is a Session and Application object?
     
Session object store information between HTTP requests for a particular user, while application object are global across users.

60. What method is used to bind data items to an ASP.NET Web control?
     
The DataBinder.Eval method binds data items to ASP.NET Web controls.

61.What is a template in the context of ASP.NET controls?
     
A template is a set of HTML or ASP.NET code displayed in a list or grid format by the Repeater, DataGrid, or DataList control.

62. How do you create a permanent cookie?
     
Setting the Expires property to MinValue means that the Cookie never expires.

63. What is the difference between a Web Service and a Web server?
     
A Web Service uses custom code to provide functions to client programs located somewhere on the Internet. A Web server listens for Internet requests, such as HTTP or SOAP requests, and responds with files. Most Web Services use a Web server to "feed" them with requests from clients and to "push" data back to client programs.

64. How to Manage State in ASP.Net?
     
There are several ways to manage a state.

    ViewState
    QueryString
    Cookies
    Session
    Application

65.What is the difference between "Web.config" and "Machine.config"?
     
   "Web.config" files apply settings to each web application.
    While "Machine.config" file apply settings to all ASP.NET applications.


66.What are the components of web form in ASP.NET?
     
There are four components of web form in Asp.net are :
    HTML controls
    Server controls
    System components.
    Data controls

67. How do you turn off cookies for one page in your site?
     
Use the Cookie.Discard Property which Gets or sets the discard flag set by the server. When true, this property instructs the client application not to save the Cookie on the user's hard disk when a session ends.

68. Which namespace is needed to implement debug and trace?
     
Debug and trace class belongs to System.Diagnostic namespace.

69.What events does the HttpSession class support?
     
The HttpSession class supports the Load and Unload events.

70.Which two properties are on every validation control?     

Control To Validate
ErrorMessage properties

71.What is the use of @Register directives?
     
@Register directive informs the compiler of any custom server control added to the page.

72. What is the difference between Authentication and Authorization?     

Authentication is the process of identifying users.
Authentication is identifying/validating the user against the credentials (username and password) and Authorization performs after authentication.
Authorization is the process of granting access to those users based on identity.
Authorization allowing access of specific resource to user.

73. What is the simplest way to write an HTML string to the output of an ASP.NET page?
     
The simplest possible way to write an HTML string is to use the Response.Write method.

74. What is the difference between Server-side and client-side code?
     
Server side code is executed at the server side on IIS in Asp.NET framework, while client side code is executed on the browser.

75. How do you change the timeout for a Session object?
     
You can change the timeout for a Session object by setting its Timeout property or by using the Web.Config file.

76. What is a bubbled event?
     
When you have a complex control, like DataGrid, writing an event processing routine for each object (cell, button, row, etc.) is quite tedious. The controls can bubble up their event handlers, allowing the main DataGrid event handler to take care of its constituents.

77.What makes a Web page dynamic?
     
Program code that you write makes a Web page dynamic. Dynamic pages respond to user input and perform useful services.

78.What are the five different ways of handling state in ASP.Net Web forms?
     
You can handle state in ASP.NET Web applications by using :
    Cookies
    Query strings
    Hidden fields
    Session
    Application objects

79.What is the difference between Server.Transfer and Response.Redirect?
     
Server.Transfer does not send any message to the browser but rather redirects the user directly from the server itself.
Response. Redirect sends message to the browser saying it to move to some different page.

80. What is the use of Smart Navigation property?
     
It is a feature provided by ASP.NET to prevent flickering and redrawing when the page is posted back.

81. What is Validation Summary?
     
It displays summary of all current validation errors on an Asp.Net page.

82. What are all the types of data types available in ASP.NET?
     
There are two types of data types availabel in Asp.Net are :

    Framework specific data type
    Language specific data type.

83.Define Page class?
     
Page class is the part of System. Web.UI namespace from which all ASP.NET pages are derived.

84.What is a PostBack?
     
The process in which a Web page sends data back to the same page on the server.

85.What data type does the RangeValidator control support?
     
Range validator control supports :
    Integer
    String
    Date

86. What is Required Field Validator?
     
It checks whether the control have any value. It is used when you want the control should not be empty.

87.What is Range Validator?
     
It checks if the value in validated controls is in that specific range.

88.What is Compare Validator?
     
It checks that the value in controls should match some specific value.

89.What is Regular Expression Validator?
     
When we want the control, value should match with a specific regular expression.

90. What is Custom Validator?
     
It is used to define user defined validation.

91. What is the difference between user and server controls?
     
User controls are created by the developer to allow for the reuse of controls that need specific functionality, while the Server controls are built-in.

92. What are the types of Authentication technique in Asp.Net?
     
There are three types of Authentication techniques are :

    Windows Authentication
    Passport Authentication
    Form Authentication

93.Which are the namespaces that are imported automatically by Visual Studio in ASP.Net?
     
There are 7 namespaces which are imported automatically :
    System
    System.Collections
    System.IO
    System.Web
    System.Web.UI
    System.Web.UI.HTMLControls
    System.Web.UI.HTMLControls

94. How can we identify that the page is Post Back?
     
Page object has an "Ispostback" property, which can be checked to know that is the page posted back.

95. How ASP.NET different from ASP?
     
Scripting is separated from the HTML, Code is compiled as a DLL, these DLLs can be executed on the server.

96.Why doesn't the .NET runtime offer deterministicdestruction?

Because of the garbage collection algorithm. The .NET garbage collectorworks by periodically running through a list of all the objects that are
currently being referenced by an application. All the objects that it doesn'tfind during this search are ready to be destroyed and the memory reclaimed.
The implication of this algorithm is that the runtime doesn't get notifiedimmediately when the final reference on an object goes awayit only finds
out during the next 'sweep' of the heap.Futhermore, this type of algorithm works best by performing the garbagecollection sweep as rarely as possible. Normally heap exhaustion is the

97.Is the lack of deterministic destruction in .NET a problem?

It's certainly an issue that affects component design. If you have objects that maintain expensive orscarce resources (e.g. database locks), you need to provide some way to tell the object to release the resource when it is done.
Microsoft recommend that you provide a method called Dispose() for this purpose. However, this causes problems for distributed objectsin a distributed system who calls the Dispose() method? Some form of referencecounting or owner shipmanagement mechanism is needed to handledistributed objectsunfortunately the runtime offers no help with this.

98.Should I implement Finalize on my class? Should Iimplement IDisposable?

This issue is a little more complex than it first appears. There are really two categories of class that require deterministic destruction the first category
manipulate unmanaged types directly, whereas the second category manipulate managed types that require deterministic destruction. An example of the first category is a class with an IntPtr member representing
an OS file handle. An example of the second category is a class with a System.IO.FileStream member.

99.What is differences between ADO and DAO?   
DAO- can access only access database
ADO- can access any databases

100. Explain What is referential integrity and how can we achieve it?   

Referential integrity preserves the defined relationships between tables when records are entered or deleted. In SQL Server, referential integrity is based on relationships between foreign keys and primary keys or between foreign keys and unique keys. Referential integrity ensures that key values are consistent across tables. Such consistency requires that there be no references to nonexistent values and that if a key value changes, all references to it change consistently throughout the database.
We can achieve this by using foreign key.

101. Explain the different types of replication? How are they used?   

Replication is used for distributing data and the execution of stored procedures across an enterprise. The replication technology allows you to make duplicate copies of your data, move those copies to different locations, and synchronize the data automatically so that all copies have the same data values.
The different types of replications are
a) transactional replication
b) merge replication

102.Explain How many objects are there in ASP?   

There are 6 objects in ASP.net
a) Server
b) Session
c) Application
d) ObjectContext
e) Response
f) Request

103.Explain What are cursors? Name four type of cursors and when each one would be applied?   

Opening a cursor on a result set allows processing the result set one row at a time.
The four API server cursor types supported by SQL Server are:
a) Static cursors
b) Dynamic cursors
c) Forward-only cursors
d) Keyset-driven cursors

104.Explain What is the STUFF function and how does it differ from the REPLACE function?   

STUFF - It deletes a specified length of characters and inserts another set of characters at a specified starting point. REPLACE -Replaces all occurrences of a specified string value with another string value.

105.Explain the use of trace utility?   

Tracing is a very important monitoring and debugging tool for distributed, multitier applications. Such applications often contain problems that can only be observed when the application is under a heavy load and the inherent randomness of a real-life environment. Trace utility allows developers and administrators to monitor the health of applications running in real-life settings.

106. What is differences between Server.Transfer and server.execute method?   

Execute method returns control to the page in which it is called once the page specified in the Execute method finishes processing, the Transfer method does not return control to the calling page.

0 comments:

Post a Comment