Showing posts with label Interview questions. Show all posts
Showing posts with label Interview questions. Show all posts

.NET Framework Interview questions

Q1)What are the debugging windows available?
Ans)

The windows which are available while debugging are known as debugging windows.

These are: Breakpoints, Output, Watch, Autos, Local, Immediate, Call Stacks, Threads, Modules, Processes, Memory, Disassembly and Registers.
-------------------------------------------
Q2)How do we step through code?
Ans)
Stepping through the code is a way of debugging the code in which one line is executed at a time.

There are three commands for stepping through code:

Step Into: This debugging mode is usually time-consuming. However, if one wants to go through the entire code then this can be used. When you step into at a point and a function call is made somewhere in the code, then step into mode would transfer the control to the first line of the code of the called function.

Step Over: The time consumed by the Step into mode can be avoided in the step over mode. In this, while you are debugging some function and you come across another function call inside it, then that particular function is executed and the control is returned to the calling function.

Step Out: You can Use Step Out when you are inside a function call and want to return to the calling function. Step Out resumes execution of your code until the function returns, and then breaks at the return point in the calling function.

Steps in visual studio
----------------------
Tools\Options -> Environment\Keyboard. The Step Into/Out commands are Debug.StepInto/Debug.StepOut.

Note that the default is F10 = StepOver and F11 = StepInto.
You can alternatively reset the key bindings because the default is what you want as well.
-----------------------------------------

Q3)Which one is not a testing tool in Dotnet Framework ?
Ans)
Select from following answers:
  1. NUNIT
  2. NANT
  3. csUnit

NANT - NAnt is a free .NET build tool based on Ant.

What are Scripting Objects?

What are Scripting Objects?
Ans)
Select from following answers:
  1. TextStream object
  2. FileSystemObject object
  3. Dictionary object
  4. All of the Above
All the above mentioned objects are said to be scripting objects

How do we check Array out of range error in C#

How do we check Array out of range error in C#
Ans)


In C# we have IndexOutOfRange exception which is used to check the index out of range exception.

Example:
try
{
------
}
catch(IndexOutOfRangeException ex)
{
Console.WriteLine("An index was out of range!");
}
catch(Exception ex)
{
Console.WriteLine("Error occured: " + ex.Message);
}

In what Software Paradigm, "Test Driven Development (TDD)" fall ?

In what Software Paradigm, "Test Driven Development (TDD)" fall ?
Ans)

Select from following answers:
  1. Agile Methodology
  2. Extreme Programming
  3. Prototype
Ans is Extreme Programming
TDD is one of the basic requirement of Extreme Programming.

Extreme Programming is based on Agile Software Development in which software quality and responsiveness is maintained to changing customer requirements. Extreme Programming enhances software development projects in 5 key ways:

Communication, simplicity, feedback, respect, and courage.

How do we read XML Schema and Data into a Dataset ?

How do we read XML Schema and Data into a Dataset ?
Ans)
We can read the XML Schema and data into Dataset using --

Dataset.ReadXml command.

example Follows :
DataSet DemoDataSet = new DataSet();
DataTable DemoDataTable = new DataTable("Table Name");
DemoDataTable .Columns.Add("Column Name", typeof(string));
DemoDataSet .Tables.Add(DemoDataTable);


string strXMLData = "Add an xml data"

System.IO.StringReader xmlSR = new System.IO.StringReader(strXMLData);

DemoDataSet .ReadXml(xmlSR, XmlReadMode.IgnoreSchema);

What is the use of Assembly Manifest ?

What is the use of Assembly Manifest ?
Ans)
Generally assembly contains a collection of data where it describes the relation between different elements in the assembly which relate to each other. This assembly manifest contains the assembly metadata. Assembly manifest can be stored in either executable file like an .exe file or .dll file with MSIL. Assembly Manifest has below mentioned information:
Assembly Name
Culture Type
Reference Information
Information on referenced Assemblies
Version Culture List of all the files in the Assembly

What is the need for Hash Table and Serialization in .Net ?

What is the need for Hash Table and Serialization in .Net ?

Ans)
The Hashtable object contains items in key/value pairs. The keys are used as indexes. We can search value by using their corresponding key.
In .NET, the class that implements a hash table is the Hashtable class.

By using Add Method we can add elements to the Hashtable as shown below:
----------
private Hashtable table = new Hashtable();

public void AddEntry(BookEntry entry)
{
table.Add( entry.GetPerson(), entry );
}
-----------
Once the Hashtable gets populated,you can search and retrieve data in it by calling the indexer for the Hashtable class as shown below:
-----------------------------
public BookEntry GetEntry(Person key)
{
return (BookEntry) table[key];
}
----------------------------------

You can also remove the records from the Hashtable by calling the Remove Method which takes a key identifying the element you want to remove as shown below:
-------------------------------------
public void DeleteEntry(Person key)
{
table.Remove( key );
}
---------------------------------------
The data populated from the Hashtable can be saved using Serialization process.
Serialization is a process where the object gets converted into a linear sequence of Bytes for storage or transmission to another location.
This process can be done by using BinaryFormater class which serializes Hashtable object to file stream.
--------------------------
public void Save()
{
Stream s = File.Open("Phone.bin", FileMode.Create, FileAccess.ReadWrite);
BinaryFormatter b = new BinaryFormatter();
b.Serialize(s, table);
s.Close();
}
-----------------------------

By using the Deserialize method, you can get back the recovered Hashtable object as shown below:
--------------------
s = File.Open("Phone.bin", FileMode.Open, FileAccess.Read);
BinaryFormatter b = new BinaryFormatter();
table = (Hashtable) b.Deserialize(s);
--------------------------