Saturday, 21 December 2013

Interview Question on Ado.Net

What Is ADO(Active data Object)

  ADO stands for ActiceX Data Objects.It was introduced few years ago as a solution to accessing data that can be found in various forms, not only over a LAN but over the internet. It replaced the data access technologies RDO(Remote Data Objects) and DAO (Data Access Objects).
The difference b/w ADO and ADO.NET is.... more 

What are the Two fundamental object in ADO.NET
There are two fundamental object in ADO.NET
(1) Data Reader
(2) Data Set
The difference b/w Data Set  and Data Reader is... more 

What is the use of command Object?
  • Execute Non Query :-Executes the command defined in the command text property against the connection defined in the connection property for a query that does not return any row (Insert, Update or Delete).Returns an integer indicating the number of rows affected by the query.
  • Execute Reader :- Executes the command defined in the command text property against the connection defined in the connection property.Returns a reader object that in connected to the resulting row set within the data base, allowing the rows to be retrieved.
  • Execute Scalar :-Executes the command defined in the command text property against the column defined in the connection property.Returns only single value the first column of the first row of the resulting row set any other returned columns and rows are discarded.
What are the advantages of ADO.NET 
  • Scalability
  • Data Source Independence
  • Interoperability
  • Strongly Typed Fields
  • Performance
What is the use of Data View 
Data View represents a complete table or can be small of rows depending on some criteria. It is the best used for sorting and finding data with in data table.
DataView dview = new DataView(dtb1);
dview = dataset.Table(0).DefaultView;

What is the Difference b/w dataset clone and copy
Dataset Clone : It only copies structure does not copy data.
Dataset Copy : Copies both structure and data.

Name of some ADO.NET object
  • Connection Object
  • DataReader Object
  • Command Object
  • DataSet Object
  • DataAdapter Object
What is the use of System.Data namespace in Ado.Net
System.Data : This contains the basic objects used for accessing and storing relational data such as dataset,datatable and data relation.

What is the Difference b/w Optimistic" and "Pessimistic" locking?
In Pessimistic locking when user wants to update data it locks the record and till then no one can update data.
In Optimistic locking multiple users can open the same record for updating, thus increase maximum concurrency.

Define Clustered Index?
The Data rows are stored in particular order.It is usually provides faster access  to data than does a non-clustered index. A table contain only one clustered index.
Define Non-Clustered Index?
The Data rows are not stored in particular order. There may be many Non-Clustered index. 
  
Difference B/w Data Set & Record set  Click here

Describe ADO.NET architecture 
ADO.NET provides the efficient way to manipulate the database. It contains the following major components are :
  • DataSet Object
  • Data Providers :
  •       ›› Connection Object :- It provides a connection to the database
           ››Command Object :- which is used to execute a command
           ››DataReader Object :-which provides a forward-only, read only, connected recordset
           ››DataAdapter Object :-which populates a disconnected DataSet with data and performs update
  • DataAdepter : - These are object that connect one or more command object to a dataset object. They provide logic that gets the data from the data store and populates the table in the dataset
  • ›› Method of DataAdepter : - 
                ››Fill Method : - Execute the select command to fill the dataset object with data from the                           data source .
                   ›› Fill Schema :- use the Select command to extract just the schema & creats on empty                               table dataset object
                   ›› Update : - Calls the respective insert command, update command, delete command for                           each inserted , delete row in the dataset. 








Interview Question on C#



Q :What is a C# ?

  • C# is a object oriented programming which is developed  by the Microsoft which is currently used on Application development in the .Net platform.
  •   It’s developed by Andres Hajasberg.
  • C# is an object oriented and user friendly. It gives security and reusability. We can develop multiple applications.
Q :What is the delegate ? 

 Delegate is a class which has the reference of a class or method. 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.
For more about  delegate click here

Q:What is the difference b/w convert.to.string and .to.string() method?
Convert function handles nulls while i.string() does not it will throw a null reference exception error.
Q:What is the difference between const and readonly?
  • Constants are dealt with at compile-time.
  • Constants support value-type variables so it is stored in stack .
  • Constants should be used when it is very unlikely that the value will ever change.

  • Read-only variables are evaluated at runtime.
  • Read-only variables can hold reference type variables so it is stored in heap.
  • Read-only variables should be used when run-time calculation is required.

Q:What are the type of comment in C# ?
    There are 3 types of comments in C# are :
  • Single line (//)
  • Multi (/* */)
  • Page/XML Comments (///).
Q:What is the difference b/w operator overloading and overriding ? 
operator overloading:-In which function name are same but the difference in only in passing perimeters. 
overriding:-In which all the function name and passing parameters are same. 

Q:What is the similarities  b/w structure and class?

  • Both can have constructors, methods, properties, fields, constants, enumeration, events and event handlers.
  • Structures and classes can implement interface.
  • Both can have delegates and events.
  • Both of them can have constructors with and without parameter.
Q:What are the wait handler? 
    Wait handles sends signals of a thread status from one thread to other thread. There are three types of wait modes are :
  • Wait One
  • Wait Any
  • Wait All
Q:What are the type of array ?
    There are three types of arrays in C# are :
  • Single-Dimensional arrays
  • Multidimensional arrays
  • Jagged arrays.
Q:What is the difference b/w System.String and System.StringBuilder classes?
  • System.String
  • 1.Its a class used to handle strings...
  • 2.Here concatenation is used to combine two strings...
  • 3.String object is used to concatenate two strings...
  • 4.The first string is combined to the other string by creating a new copy in the memory as a string object, and then the old string is deleted..
  • 5.we say "Strings are immutable". ..

  • String Builder....
  • 1.This is also the class used to handle strings...
  • 2.Here Append method is used...
  • 3.Here, Stringbuilder object is used...
  • 4.Insertion is done on the existing string...
  • 5.Usage of StringBuilder is more efficient in case large amounts of string manipulations have to be performed
Q:What is the difference b/w boxing and unboxing ? 
When a value type is converted to the object type, the process is known as boxingand,alternatively, when an object type is converted to the value type, the process is known as unboxing.

Q:What is the difference b/w dataset.clone and dataset.copy ?
Dataset.clone copies just the structure of dataset (including all the datatables, schemas, relations and constraints.); however it doesn't copy the data.
Dataset.copy copies both the dataset structure and the data.
Q: what is the enum ?
It is used to define constants.
Q: How to prevent your class from being inherited by another class?
Yes. The keyword "sealed" will prevent the class from being inherited.
Q:Why is the virtual keyword used in code?
The Virtual keyword is used in code to define methods and the properties that can be overridden in derived classes.
Q:What is jagged array ?
A jagged array is an array whose elements are arrays. The elements of a jagged array can be of different dimensions and sizes. A jagged array is sometimes called an "array-of-arrays."











IsPostBack


Q: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.

Q:What is a Post Back:-
The Process in which a web page sends Data Back to the same page on the server.

View State IN Dot Net

View State in Dot Net:

Introduction:- It is used to maintain the state of controls during Page post back and if we save any control value or anything in view state we can access those value through out the page whenever it require for that check.

View state information stored in Html Hidden Field.

Q : How do you enable or disable a ViewState for a control on the page?
Ans : Every ASP.NET control has a property called EnableViewState. If EnableViewState is set to true ViewState is enabled for the control. If EnableViewState is set to false ViewState is disabled for the control.
Q : How do you enable or disable a ViewState at the page level?
Ans : At the page level you can enable or disable ViewState using EnableViewState property of the page.
Q : What is the name of the hidden form field in which ViewState of the page is saved?
Ans : _ViewState
Q : What are the performance implications of ViewState?
Ans : ViewState is usually good to retain the state of the controls on the webform across postbacks. If you have a huge DataGrid with tons of data being loaded on every page load. It is a good idea to disable the ViewState of the DataGrid for the page to load faster. If the ViewState of a large DataGrid is not disabled, ViewState can easily get very large, on the order of tens of kilobytes. Not only does the __ViewState form field cause slower downloads, but, whenever the user posts back the Web page, the contents of this hidden form field must be posted back in the HTTP request, thereby lengthening the request time, as well.
Q : When does ViewState restoration happens?
Ans : During the Page_Init event
Q : What are the disadvantages of using ViewState?
Ans : 1. On all page visits, during the save view state stage the Page class gathers the collective view state for all of the controls in its control hierarchy and serializes the state to a base-64 encoded string. (This is the string that is emitted in the hidden __ViewState form filed.) Similarly, on postbacks, the load view state stage needs to deserialize the persisted view state data, and update the pertinent controls in the control hierarchy.

2. The __ViewState hidden form field adds extra size to the Web page that the client must download. For some view state-heavy pages, this can be tens of kilobytes of data, which can require several extra seconds (or minutes!) for modem users to download. Also, when posting back, the __ViewState form field must be sent back to the Web server in the HTTP POST headers, thereby increasing the postback request time.
Q : Is ViewState encoded?
Ans :Yes, ViewState is base-64 encoded.
Q : What happens during the Page_Init event?
Ans : The server controls are loaded and initialized from the Web form’s view state. This is the first step in a Web form’s life cycle.

Coding For View State

protected void page_load(object sender,Event args e)

{

if (! ispostback)

{

string str = "welcome to Asp.net-munesh blog";

if(view state["sample text"]==NULL )

{

view state["sample text"]==str;

}}}

protected void btnclick_click (object sender,Event args e)

{

lblstring.text = viewstate["sample text"].to string();

} 



C# program Selection Sorting

Selection sort is a straightforward sorting algorithm. This algorithm search for the smallest number in the elements array and then swap i...