What is the difference between “DataSet” and “DataReader” ?
Twist :- Why is DataSet slower than DataReader ? Fourth point is the answer to the twist.
Following are the major differences between “DataSet” and “DataReader” :-
- DataSet is a disconnected architecture, while “DataReader” has live connection while reading data. If we want to cache data and pass to a different tier “DataSet” forms the best choice and it has decent XML support.
- When application needs to access data from more than one table “DataSet” forms the best choice.
- If we need to move back while reading records, “datareader” does not support this functionality.
- But one of the biggest drawbacks of DataSet is speed. As “DataSet” carry considerable overhead because of relations, multiple tables etc speed is slower than “DataReader”. Always try to use “DataReader” wherever possible, as it’s meant specially for speed performance.
What are abstract classes ?
Following are features of a abstract class :-
- You can not create a object of abstract class
- Abstract class is designed to act as a base class (to be inherited by other classes). Abstract class is a design concept in program development and provides a base upon which other classes are built.
- Abstract classes are similar to interfaces. After declaring an abstract class, it cannot be instantiated on its own, it must be inherited.
- In VB.NET abstract classes are created using “MustInherit” keyword.In C# we have “Abstract” keyword. √ Abstract classes can have implementation or pure abstract methods which should be implemented in the child class.
What is a Interface ?
Interface is a contract that defines the signature of the functionality. So if a class is implementing a interface it says to the outer world, that it provides specific behavior. Example if a class is implementing Idisposable interface that means it has a functionality to release unmanaged resources. Now external objects using this class know that it has contract by which it can dispose unused unmanaged objects.
· Single Class can implement multiple interfaces.
· If a class implements a interface then it has to provide implementation to all its methods.
What is difference between abstract classes and interfaces?
Following are the differences between abstract and interfaces :-
- Abstract classes can have concrete methods while interfaces have no methods implemented.
- Interfaces do not come in inheriting chain, while abstract classes come in inheritance.
What is a delegate ?
Delegate is a class that can hold a reference to a method or a function. Delegate class has a signature and it can only reference those methods whose signature is compliant with the class. Delegates are type-safe functions pointers or callbacks.
What is the difference between delegate and events?
- Actually events use delegates in bottom. But they add an extra layer on the delegates, thus forming the publisher and subscriber model.
- As delegates are function to pointers they can move across any clients. So any of the clients can add or remove events, which can be pretty confusing. But events give the extra protection by adding the layer and making it a publisher and subscriber model.
What are the different accessibility levels defined in .NET ?
Following are the five levels of access modifiers :-
- Private : Only members of class have access.
- Protected :-All members in current class and in derived classes can access the variables.
- Friend (internal in C#) :- Only members in current project have access to the elements.
- Protected friend (protected internal in C#) :- All members in current project and all members in derived class can access the variables.
- Public :- All members have access in all classes and projects.
Can you prevent a class from overriding ?
If you define a class as “Sealed” in C# and “NotInheritable” in VB.NET you can not inherit the class any further.
What are similarities between Class and structure ?
Following are the similarities between classes and structures :-
- Both can have constructors, methods, properties, fields, constants, enumerations, events, and event handlers.
- Structures and classes can implement interface.
- Both of them can have constructors with and without parameter.
- Both can have delegates and events.
What is the difference between Class and structure’s ?
Following are the key differences between them :-
- Structure are value types and classes are reference types. So structures use stack and classes use heap. √ Structures members can not be declared as protected, but class members can be. You can not do inheritance in structures.
- Structures do not require constructors while classes require.
- Objects created from classes are terminated using Garbage collector. Structures are not destroyed using GC.
What does virtual keyword mean ?
They are that method and property can be overridden.
What is the use of “OverRides” and “Overridable” keywords ?
Overridable is used in parent class to indicate that a method can be overridden. Overrides is used in the child class to indicate that you are overriding a method
What is ArrayList ?
Array is whose size can increase and decrease dynamically. Array list can hold item of different types. As Array list can increase and decrease size dynamically you do not have to use the REDIM keyword. You can access any item in array using the INDEX value of the array position.
What’s a HashTable ?
Twist :- What’s difference between HashTable and ArrayList
You can access array using INDEX value of array, but how many times you know the real value of index. Hashtable provides way of accessing the index using a user identified KEY value, thus removing the INDEX problem
.What are queues and stacks ?
Queue is for first-in, first-out (FIFO) structures. Stack is for last-in, first-out (LIFO) structures.
What is ENUM ?
It’s used to define constants.
What is nested Classes ?
Nested classes are classes within classes. In sample below “ClsNested” class has a “ChildNested” class nested inside it.
What is the difference between System.String and System.StringBuilder classes?
System.String is immutable; System.StringBuilder can have mutable string where a variety of operations can be performed.
What’s difference between Datagrid, Datalist and repeater ?
· Datagrid, Datalist and Repeater are all ASP.NET data Web controls.
· They have many things in common like DataSource Property, DataBind Method ItemDataBound and ItemCreated.
· When you assign the DataSource Property of a Datagrid to a DataSet then each DataRow present in the DataRow Collection of DataTable is assigned to a corresponding DataGridItem and this is same for the rest of the two controls also. But The HTML code generated for a Datagrid has an HTML TABLE <ROW> element created for the particular DataRow and its a Table form representation with Columns and Rows.
· For a Datalist its an Array of Rows and based on the Template Selected and the RepeatColumn Property value We can specify how many DataSource records should appear per HTML <table> row. In short in datagrid we have one record per row, but in datalist we can have five or six rows per row.
· For a Repeater Control, the Datarecords to be displayed depends upon the Templates specified and the only HTML generated is the due to the Templates.
· In addition to these, Datagrid has a in-built support for Sort, Filter and paging the Data, which is not possible when using a DataList and for a Repeater Control we would require to write an explicit code to do paging.
From performance point of view how do they rate ?
Repeater is fastest followed by Datalist and finally datagrid.
1. How different are interface and abstract class in .Net?
Abstract classes can not be instantiated it can have or cannot have abstract method basically
known as mustinherit as the methods are static in nature
where interfaces are the declaration and r defined where they are called used for dynamic
2. What is an interface and what is an abstract class? Please, expand by examples of using
both. Explain why?
Abstract classes are closely related to interfaces. They are classes that cannot be instantiated,
and are frequently either partially implemented, or not at all implemented. One key difference
between abstract classes and interfaces is that a class may implement an unlimited number of
interfaces, but may inherit from only one abstract (or any other kind of) class. A class that is
derived from an abstract class may still implement interfaces. Abstract classes are useful when
creating components because they allow you specify an invariant level of functionality in some
methods, but leave the implementation of other methods until a specific implementation of
that class is needed. They also version well, because if additional functionality is needed in
derived classes, it can be added to the base class without breaking code.
3. What is an Interface?
An interface is not a class. It is an entity that is defined by the word Interface. An interface has
no implementation; it only has the signature or in other words, just the definition of the
methods without the body. As one of the similarities to Abstract class, it is a contract that is
used to define hierarchies for all subclasses or it defines specific set of methods and their
arguments. The main difference between them is that a class can implement more than one
interface but can only inherit from one abstract class. Since C# doesn?t support multiple
inheritance, interfaces are used to implement multiple inheritance.
4. What methods are fired during the page load?
When the page loads the Init() method is invoked which initializes the global variables and the page is instantiated then the Load() method is called to load the page into the server memory. Once the page is loaded into the server the page requires to be pre-rendered for a brief period of time before showing the page as a HTML page to the client for this the pre-render() method is invoked. Lastly the Unload() method is triggered after the page loading is completed.
5. State the difference between Server.Transfer and Response.Redirect
Server.Transfer instructs the web server to directly go to the requested page without performing any round trip to the client who initiated that event. It is for this reason that the url of the page doesnot change to reflect it on the clients browser. It is used because it is faster with reduced server overhead. Response.Redirect is used to redirect the browser of the client to another page or site. A client round trip is made in this method due to which the url of the client’s browser is updated.
6. What is ViewState?
A web application is stateless in nature which means that on every post back the page gets loaded freshly flushing all the data values. To deal with this problem state management is required which can be done by many ways in ASP.NET one among them is ViewState. In ViewState the state of the objects (serializable) are stored in the hidden fields of a page. Then this ViewState acts as an object carrier between the client and the Server and it eradicates the need for storing data in server memory saving precious resources.
7. What is the difference between ViewState and SessionState?
In ViewState the the object are serialized and stored in hidden fields within the page. After the post back the server updates this field with the new set of values for which any older value is destroyed. In SessionState a part of the memory of the server for a particular client is used to store client specific data. This data are available till the session is active after the session is abandoned these data are deleted. (or)
View State persist the values of controls of particular page in the client (browser) when post
back operation done. When user requests another page previous page data no longer available.
SessionState persist the data of particular user in the server. This data available till user close
the browser or session time completes.
8. Explain connected and disconnected architecture in ADO.NET.
In connected architecture once the connection is established by Open() method a dedicated connection is maintained within that period of time all the data manipulation is done and after completion the connection is closed by Close(). But in disconnected architecture a mirror image of the database is brought on the client side and the connection suspends after that and that mirror image is updated by the client. When the update() is called the connection gets alive to update the database. This saves a huge connection bandwidth in e-commerce applications.
9. What are the different types of caching?
Caching is a common method used to speed up the search process of frequently accessed data in a small memory (sometime called as cache memory). For web applications it is used to hold the page requests in order to reuse them cutting the hassle of recreating them. This enhances the response time and makes the whole process work faster. ASP.NET has 3 kinds of caching schemes Output, Fragment and Data Caching.
10. State the difference between Page.RegisterClientScriptBlock and Page.RegisterStartupScript. For returning blocks of client-side script consisting functions RegisterClientScriptBlock is used. While RegisterStartupScript is used for returning blocks of client-script not packaged in functions i.e. codes that are required to execute when the page is being loaded. Near the end of the document the latter positions of the scripts get blocked so elements on the page that the script interacts are loaded before the script can run.
11. What are Assemblies?
Assembly is a single deployable unit that contains information about the implementation of
classes, structures and interfaces. it also stores the information about itself called metadata and
includes name and verison of the assembly, security information, information about the
dependencies and the list of files that constitute the assembly.
Assembly also contains namespaces. In the .Net Framework, applications are deployed in the
form of assemblies.
12. 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 (By setting the Cookie. Discard property false). When true, this property instructs the client application not to save the Cookie on the users hard disk when a session ends.
it can be turned off by mentioning cookie state= false in web.config file
17. How does VB.NET/C# achieve polymorphism?
VB.Net / C# provide polymorphism through the following mechanisms:
1. Inheritance - base class provides overridable methods which are re-implemented in derived
2. Interface - different class can implement same interface, resulting in different
implementations of interface methods.
3. Virtual methods - achieve runtime polymorphism.
18. What are value types and reference types?
Value type - bool, byte, chat, decimal, double, enum , float, int, long, sbyte, short, strut, uint,
ulong, ushort. Value types are stored in the Stack
Reference type - class, delegate, interface, object, string. Reference types are stored in the Heap
20. What is the difference between thread and process?
Thread - is used to execute more than one program at a time.
process - executes single program
21. What is Full Trust?
Your code is allowed to do anything in the framework, meaning that all (.Net) permissions are
granted. The GAC has Full Trust because it’s on the local HD, and that has Full Trust by default,
you can change that using caspol .
26. Which method do you invoke on the DataAdapter control to load your generated
dataset with data?
dataAdapter.Fill(ds). The beauty of this method is it automatically implicitly opens the
connection to database and closes it once done.We dont need to worry about opening and
closing the connection to the database.