Technical interview question in Igate
Recently attended a technical interview for 4-6 years experienced persons for ASP.Net profile in IGate. I am listing down only the theoretical questions but there were other questions based on my project experience.
1.What is an interface?
An interface is not a class but an object with a set of methods. The method inside an interface has only method definitions without ant body. An interface is used to implement multiple inheritance in code. This feature of an interface is quite different from that of abstract classes because a class cannot derive the features of more than one class but can easily implement multiple interfaces. Variables in interface must be declared as public, static, and final while methods must be public and abstract.
2.What are abstract classes? What are the distinct characteristics of an abstract class?
An abstract class is a class that cannot be instantiated and is always used as a base class. We cannot instantiate an abstract class directly. This implies that we cannot create an object of the abstract class; it must be inherited. We can have abstract as well as non-abstract members in an abstract class. We must declare at least one abstract method in the abstract class. An abstract class is always public. An abstract class is declared using the abstract keyword. The basic purpose of an abstract class is to provide a common definition of the base class that multiple derived classes can share.
3.What is the difference between Abstract Class and Interface?(It is asked in almost all the interview.It has been asked to me 100 times)
An Interface contains Methods with only signatures and no body. An Abstract class contains method signatures with or without body.
A class can implement several interfaces inside it.A class can inherit from a single Abstract class.
By default, interface has public access modifiers.It cannot use any other access modifiers. An Abstract class can have any access modifiers.
No variables and constants can be defined in a class.An abstract class can have variables and constants.
4.What different type of connection Architecture we have in ASP.Net?
There two types of connection in Ado.Net. They are connected Architecture and disconnected architecture.
In connected architecture, we don't have to open and close the connection manually. A data-reader is used in connected architecture to read the data from the database row by row. This reduces the performance efficiency as we have to each time hit the server each time and the traffic for the server also increases.
In disconnected architecture, we have to manually open and close the connection. A data-set or data-table is used in disconnected architecture to read the data from the database at a time and store it in memory.
5.Can you allow a class to be inherited, but prevent a method from being overridden in C#?
Yes. Just declare the class public and make the method sealed.
6.What is a View State?
View State is one of the state management methods used to retain the page and it's control values between post backs. It Store the values of page or control properties that you define. One bit of state that does not need to be persisted across post-backs is the control's properties specified in the declarative syntax, since they are automatically reinstated in the page's instantiate stage. View State is a client side state management.
7.Difference between Session and View State?
Session is more secure than View State as it is stored in server side memory and creates a unique session id for each session.
8.Difference between dispose and finalize methods in C#.
Finalize method is implicitly called by GarbageCollector to delete the object if it is no longer in use whereas Dispose method is explicitly called inside a class through IDisposible interface to forcefully remove the object
and its references.
9.What are the differences between value type and reference type?
Value type contain variable and reference type does not containing any direct value.
Memory is allocated in managed heap in reference type and in value type memory allocated in stack.
Example for Reference type –class, for value type-struct, enumeration
10.What is a Delegate?
Delegate is an object that holds the reference to methods in c#. It is same as a function pointer in C.
11.What is an Assembly?
An assembly exists as a .DLL or .EXE that contains MSIL code that is executed by CLR. An assembly contains interface and classes, it can also contain other resources like bitmaps, files etc. It carries version details which are used by the CLR during execution. Two assemblies of the same name but with different versions can run side-by-side enabling applications that depend on a specific version to use assembly of that version.
12.What is difference between Custom control and User control?
A custom control is a loosely coupled control which can be used across various applications.
We need to only include its reference (.dll) to the project and it can be added to your toolbox.
You can also keep it inside a class library.
Main difference between User Controls and Custom Controls are:
1. UC is specific to your application but CC can be used across various applications.
2. CC can be added to your application toolbox but UC cannot be added to the toolbox.
3. CC defines UI in a Resource Dictionary whereas UC defines UI as a normal xaml page.
4. To create a UC just add a new webform and add its reference to your page by declaring @Register directive. But to create a CC we need to add the Assemblies "System.Web.UI.Control" or "System.Web.UI.WebControls.WebControl". After the CC is created we need to add the dll into the bin folder of the "wwwRoot" directory.
13.What do you mean by Postback in ASP.Net?
A postback is a request sent from a client to server from the same page user is already working with. When we refresh our page or we submit some page, then the data of the current page is send back to the server.
14.What are different State Management Methods?
Client-side state management
This maintains information on the client's machine using Cookies, View State, and Query Strings.
Cookies
A cookie is a small text file on the client machine either in the client's file system or memory of client browser session. Cookies are not good for sensitive data. Moreover, Cookies can be disabled on the browser. Thus, you can't rely on cookies for state management.
View State
Each page and each control on the page has View State property. This property allows automatic retention of page and controls state between each trip to server. This means control value is maintained between page postbacks. Viewstate is implemented using _VIEWSTATE, a hidden form field which gets created automatically on each page. You can't transmit data to other page using view state.
Querystring
Query strings can maintain limited state information. Data can be passed from one page to another with the URL but you can send limited size of data with the URL. Most browsers allow a limit of 255 characters on URL length.
Server-side state management
This kind of mechanism retains state in the server.
Application State
The data stored in the application object can be shared by all the sessions of the application. Application object stores data in the key value pair.
Session State
Session State stores session-specific information and the information is visible within the session only. ASP.NET creates unique sessionId for each session of the application. SessionIDs are maintained either by an HTTP cookie or a modified URL, as set in the application's configuration settings. By default, SessionID values are stored in a cookie.
Database
Database can be used to store large state information. Database support is used in combination with cookies or session state
This is very useful questions thanks dipti