Saturday, July 30, 2011

C# and .NET Framework interview questions:- What is Multi-targeting in .NET?

Multi-targeting: - Multi-targeting is the ability to specify the version of the
.NET Framework that your application requires to run and have the matching
experience while developing it with Visual Studio’s Integrated Development
Environment (IDE).

Visual Studio 2010 multi-targeting enables you to take advantage of the latest
enhancements to Visual Studio without having to upgrade Web sites or Web
services to the latest version of the .NET Framework. This lets you use Visual
Studio 2010 to maintain and develop your Web applications that use earlier
versions of the .NET Framework.

Let’s see a small demonstration on Multi-targeting.

Create a new project as following diagrams.




As you can see that we have selected ASP.NET Web Application which is
targeting the .NET Framework 4.0 with this project, Visual Studio 2010 will
automatically filter the toolbox controls and all the properties which are
supported in .NET framework 4.0.


Now, let’s see which are the toolbox controls and the properties are available
while selecting the .NET Framework 4.0.




Similarly, let’s see when we add reference what the version is been used
currently.




As you can see in the above diagram the current version is 4.


Now, let’s see how we change the .NET Framework 4.0 to 2.0.


As soon as you click on properties a new window will open like below window
from that select the .NET Framework to 2.0.






As soon as you change the .NET Framework to 2.0, Visual Studio 2010 will
automatically filter the toolbox controls and shows only those controls that are
shipped in .NET Framework 2.0.


As you can see that few of the control are not available now in the toolbox
as we have seen in .NET Framework 4.0 toolbox.

Similarly, let’s see what happen when add reference.







Now, you can see that the current version used is 2.

So, multi-targeting enables you to take advantage of the latest enhancements to
Visual Studio without having to upgrade Web sites or Web services to the latest
version of the .NET Framework.


Following is the video on different kind of questions that are asked in C# and .NET interviews: -





Get our more C# and .NET Framework interview questions for preparation.

Regards,

Also Visit for more author’s blog on C# and .NET framework interview questions

Thursday, July 28, 2011

C# and .NET interview questions: - What is the difference between Grid view, Data list, and repeater?

Following is one of the basic but most asked .NET interview questions: -

Grid view and data grid by default display all the data in tabular format i.e.
in table and rows. Developer has no control to change the table data display of
datagrid.

Data list also displays data in a table but gives some flexibility in terms of
displaying data row wise and column wise using the repeat direction property.

Repeater control is highly customizable. It does not display data in table by
default. So you can customize from scratch the way you want to display data.

Also view an interesting video on regular expressions as follows: -





Get our more C# and Dotnet interview questions for preparation.

Regards,

Also Visit for more author’s blog on Most asked c# interview questions

Wednesday, July 27, 2011

Java and Web service interview questions: - What are the different approaches in making Web service?

An interesting Java interview question asked in most of the interviews while
discussing topic on web services. There are basically two approaches in making
web service: -

1) WSDL first Implemention second: In this case the Web service definition
language XML is made first and using the same the web service bean classes are
generated which implement the necessary functionality

Since WSDL defines Contract this is also known as Contract first


2)Implementation first WSDL second: This approach is used whenever legacy code
is available which needs to be exposed as service. So here implementation is
already available and hence only contract needs to be created using WSDL.

Following is the introductory video on Webservice for the one's who are new to
this topic: -






View more video on Java interview questions

Regards,

Click for more author's Java interview questions



Tuesday, July 26, 2011

C# and .Net Interview Questions”- Why String Builders are faster than strings?


Strings: - strings are also called as immutable because every time you
store a new value in string a new copy is created in the memory location.





String builders: - string builders are also called as mutable because
every time you store a new value in string builder

it actually appends the value in the memory location. This means insertion
is done on existing string.

Let’s demonstrate a small example which will give a clear idea on who is faster
string builder or string.

This is very simple three steps procedure as follows.

Step1: -

Create a new console application like below diagrams.


Go to file > New > Project > Console Application and Click Ok.




Step2: -


Import System.Text namespace in your application.

usingSystem.Text;

Step3: -

Write the below code snippet in your main class.

staticvoid Main(string[] args)
{
while (true)
{
Console.WriteLine("*********Begin Test*********");
Console.WriteLine("============================");
Console.WriteLine("Creating string");
Console.WriteLine();//for having a gap in the lines.
List<string>strlist = newList<string>();
for (int i = 0; i < 30000; i++)
{
strlist.Add(i.ToString());
}
Console.WriteLine("Time taken by string to concate....");
Console.WriteLine();
DateTime start = DateTime.Now;
stringConcateString = string.Empty;
foreach (strings instrlist)
{
ConcateString += s + "";
}
TimeSpan time = (DateTime.Now - start);
Console.WriteLine("Total Time : {0} MilliSeconds", time);
Console.WriteLine("============================");
Console.WriteLine("Creating StringBuilder");
Console.WriteLine();
start = DateTime.Now;
StringBuildersb = newStringBuilder();
foreach (strings instrlist)
{
sb.Append(s + "");
}
time = (DateTime.Now - start);
Console.WriteLine("Time taken by StringBuilder to concate....");
Console.WriteLine();
Console.WriteLine("Total Time : {0} MilliSeconds", time);
Console.WriteLine();
Console.WriteLine("**********End Test**********");
Console.ReadLine();
}

Now run your application and you will see the result like below diagram.


In the above result you can see that the time taken by the string to concateis
greater than the time taken by the string builder to concate, this indicates that the string builders performs faster than the strings.


For more information about generic, please watch the below video.



Please click here to see more C# and Dotnet interview questions

Regards,

Visit Authors blog for more Most asked c# interview questions

Monday, July 25, 2011

C# and .NET interview questions:- What is Serialization? Deserialization and how do you do it?

This is one of the most typical interview questions, which are asked in almost all of the interviews and is the favorable question of the interviewers.
Serialization: -“Serialization” is a process of converting an object into a stream of bytes.

Deserialization: - “Deserialization” is reverse of “serialization”, where stream of bytes are converted back in to an object.

Let’s see a simple example how exactly we can do “serialization” and “deserialization”.


It’s very simple four steps procedure as follows.

Step1: - create a new “window application” like below diagram.




Step2: - Now create a customer class in “Form1.cs” file.
[Serializable]
publicclassCustomer
{
publicstringCustomerCode;
publicstringCustomerName;
}

Step3: - Now, we will see how exactly “serialization” is done.

Import the following namespace
using System.IO;
usingSystem.Runtime.Serialization;
usingSystem.Runtime.Serialization.Formatters.Binary;

privatevoidSerialize_Click(object sender, EventArgs e)
{
Customerobj = newCustomer();// created instance of the customer class
obj.CustomerCode = textBox1.Text;
obj.CustomerName = textBox2.Text;
IFormatter formatter = newBinaryFormatter();
Streamstream = newFileStream("E:\\Customer.bin", FileMode.Create, FileAccess.Write, FileShare.None);
formatter.Serialize(stream, obj);
stream.Close();
textBox1.Text = "";
textBox2.Text = "";
}

Step4: - Similarly, we will do for “deserialization”.

privatevoidDeserialize_Click(object sender, EventArgs e)
{
IFormatter formatter = newBinaryFormatter();
Streamstream = newFileStream("E:\\Customer.bin", FileMode.Open, FileAccess.Read, FileShare.Read);
Customerobj = (Customer)formatter.Deserialize(stream);
stream.Close();
textBox1.Text = obj.CustomerCode;
textBox2.Text = obj.CustomerName;
}

Once you have completed all the above steps now you can run your application and see the respective result.

View more C# and Dotnet interview questions

Regards,

View more authors learning tutorials on Most asked c# interview questions

Sunday, July 24, 2011

C# and .NET interview questions: What is Delay signing?

During development process you will need strong name keys to be exposed to developer which is not a good practice from security aspect point of view. In such situations you can assign the key later on and during development you can use delay signing
Following is process to delay sign an assembly:
• First obtain your string name keys using SN.EXE.
• Annotate the source code for the assembly with two custom attributes from
System.Reflection: AssemblyKeyFileAttribute, which passes the name of the file
containing the public key as a parameter to its constructor. AssemblyDelaySignAttribute, which indicates that delay signing, is being used by passing true as a parameter to its constructor. For example as shown below:

[Visual Basic]
<Assembly: AssemblyKeyFileAttribute ("myKey.snk")>
<Assembly: AssemblyDelaySignAttribute (true)>
[C#]
[Assembly: AssemblyKeyFileAttribute ("myKey.snk")]
[Assembly: AssemblyDelaySignAttribute (true)]

The compiler inserts the public key into the assembly manifest and reserves
space in the PE file for the full strong name signature. The real public key
must be stored while the assembly is built so that other assemblies that
reference this assembly can obtain the key to store in their own assembly
reference.
• Because the assembly does not have a valid strong name signature, the verification of that signature must be turned off. You can do this by using the –Vr option with the Strong Name tool. The following example turns off verification for an assembly called myAssembly.dll.
Sn –Vr myAssembly.dll

• Just before shipping, you submit the assembly to your organization signing
authority for the actual strong name signing using the –R option with the Strong
Name tool. The following example signs an assembly called myAssembly.dll with a
strong name using the sgKey.snk key pair.

Sn -R myAssembly.dll sgKey.snk 
You can view video on regular expressions as follows: -




View more C# and Dotnet interview questions


Regards,

View more authors learning tutorials on Most asked c# interview questions

Saturday, July 23, 2011

.NET and ASP.NET interview questions: - How to create a simple “Master Page” in ASP.NET?

Master Page: - Master pages let you make a consistent layout for your application, you can make one master page that holds the layout/look & feel and common functionality for your whole application and upon this master page, you can build all the other pages, we call these pages Content Pages. So simply you can build your master page and then build content pages, and while creating the content pages you bind them to the master page you have created before, those two pages are merged at runtime to give you the rendered page.
Let’s see a practical demonstration how exactly we can create “Master Page” in your application.

In order to create a simple “Master page” you need to follow the following steps.

Step 1: - Create a new project > select ASP.NET Empty Web Application.



Step 2: - Right click on the project > select Add >Add new item > select “Master Page” and click Add.



As soon as you click on Add a new file will be created with .master extension like below diagram.



Step 3: - Now just place the content’s you want to keep constant in our application.



Step 4: - just follow the below diagrams to add forms to our application.

Right click on the project > select Add >Add new item > select “Web Form using Master Page” and click Add.



As soon as you click on add, a new window will appear like below diagram from that select your “master page name” and click ok.



Similarly, if you want to add more pages in our application just follow the Step 4.

Once you have done with above steps, now you can run our application and see the output with master page.

View the following video on Single sign-on using forms authentication in ASP.NET



View more .NET and ASP.NET interview questions

Regards,

View more authors learning tutorials on .NET and ASP.NET interview questions

Wednesday, July 20, 2011

.NET and ASP.NET interview questions: - Explain an application domain?

This is an interesting question asked in most of the interviews and favorite question of 3 interview takers out of 5.
So proceed with the following answer: -

Earlier “PROCESS” was used as security boundaries. One process has its own
virtual memory and does not overlap the other process virtual memory; due to
this, one process cannot crash the other process. Therefore, any problem or
error in one process does not affect the other process. In .NET, they went
one-step ahead introducing application domains. In application domains, multiple
applications can run in same process without influencing each other. If one of
the application domains throws error it does not affect the other application
domains. To invoke method in an object running in different application domain
.NET remoting is used.




View the following video on ASP.NET Authentication and Authorization as follows:-




View more .NET and ASP.NET interview questions

Regards,

View more authors learning tutorials on .NET and ASP.NET interview questions

Tuesday, July 19, 2011

C# and .NET interview questions - What is the difference between static polymorphism and dynamic polymorphism?

Static Polymorphism: - Static Polymorphism means “Compile” time polymorphism or “Early binding”.

Method Overloading is an example of Static Polymorphism, where method name is same with different parameters and implementation.

Example: -

Below is the simple code snippet for Method Overloading.

public class StaticPoly
{
public void Display(int x)
{
Console.WriteLine("Value of x:"+x);
}
public void Display(int x, int y)
{
int z = 0;
z = x + y;
Console.WriteLine("Addition of x and y is:"+ z);
}
static void Main(string[] args)
{
StaticPoly Obj = new StaticPoly();
Obj.Display(10);
Obj.Display(10,3);
Console.ReadLine();
}
}

In the above code snippet you can see that we have two methods with same name but with different parameters and implementation.
Dynamic polymorphism: - Dynamic polymorphism means “Runtime” time polymorphism or “Late binding”.

Method Overriding is an example of Dynamic Polymorphism, where the base class
method is overridden by override keyword and its implementation is also changed.


Example: -

Below is the simple code snippet for Method Overriding.

class A
{
public virtual void Display()
{
System.Console.WriteLine("Base Class A::Display");
}
}

class B : A
{
public override void Display()
{
System.Console.WriteLine("Derived Class B::Display");
}
}

class Demo
{
public static void Main()
{
A b;
b = new A();
b.Display();

b = new B();
b.Display();
Console.ReadLine();
}
}

In the above code snippet you can see that we have two methods with same name,
same signature but with different implementations.

View following one of most asked question on “What is Generics?”


See more videos on C# and Dotnet interview questions

Regards,

View authors more tutorials on Most asked c# interview questions









Monday, July 18, 2011

SQL Server interview questions: - Describe DBCC?

DBCC (Database Consistency Checker Commands) is used to check logical and
physical consistency of database structure.DBCC statements can fix and detect
problems. These statements are grouped in to four categories:-

• Maintenance commands like DBCC DBREINDEX, DBCC DBREPAR etc, they are mainly
used for maintenance tasks in SQL SERVER.

• Miscellaneous commands like DBCC ROWLOCK, DBCC TRACEO etc, they are mainly
used for enabling row-level locking or removing DLL from memory.

• Status Commands like DBCC OPENTRAN, DBCC SHOWCONTIG etc , they are mainly used
for checking status of the database.

• Validation Commands like DBCC CHECKALLOC, DBCCCHECKCATALOG etc , they perform
validation operations on database.

Note :- Check MSDN for list of all DBCC commands, it is very much possible specially during
DBA interviews they can ask in depth individual commands.

Below is a sample screen in which DBCC SHOWCONTIG command is run. DBCC
SHOWCONTIG is used to display fragmentation information for the data and indexes
of the specified table.In the sample screen “Customer” table is checked for
fragmentation



DBCC SHOWCONTIG command in action.

Fragmentation information. If “Scan density” is 100 then everything is contigious.The above image has scan density of 95.36% which is decent percentage. So such type of useful information can be collected by DBCC command and database performance and maintenance can be improved.


Click and get more.NET and SQL Server interview questions

Regards,

Visit for more author’s blogs .NET and SQL Server interview questions





Tuesday, July 12, 2011

C# and ADO.NET interview questions :- What is the difference between Dataset.clone() and Dataset.copy()?

The answer is the easy , people just get confused by the word clone and copy as they almost mean same things.
Dataset.clone(): The clone function only copies the structure of the dataset, including all schemas, relations, and constraints but it does not copy data.

Dataset.copy(): The copy function copies both the structure and data.

Following is the SQL server interview questions which shows difference between unique key and primary key.




Please click here to see more C# and ADO.NET Interview questions

Regards,


Visit Authors blog for more C# and ADO.NET Interview questions

Monday, July 11, 2011

.Net Interview Questions:- How does VB.NET differ from C#?

Well this is the most debatable issue in .NET community and people treat
languages like religion. It is a subjective matter which language is best. Some
like VB.NET’s natural style and some like professional and terse C# syntaxes.
Both use the same framework and speed is very much equivalents. Still let us
list down some major differences between them:-


Advantages VB.NET:-

• Has support for optional parameters that makes COM interoperability much easy.

• With Option Strict off late binding is supported.Legacy VB functionalities can
be used by using Microsoft.VisualBasic namespace.

• Has the WITH construct which is not in C#.

• The VB.NET parts of Visual Studio .NET compiles your code in the background.
While this is considered an advantage for small projects, people creating very
large projects have found that the IDE slows down considerably as the project
gets larger.


Advantages of C#


• XML documentation is generated from source code but this is now been
incorporated in Whidbey.

• Operator overloading which is not in current VB.NET but is been introduced in
Whidbey

• Use of this statement makes unmanaged resource disposal simple.

• Access to Unsafe code. This allows pointer arithmetic etc, and can improve
performance in some situations. However, it is not to be used lightly, as a lot
of the normal safety of C# is lost (as the name implies).This is the major
difference that you can access unmanaged code in C# and not in VB.NET.



Please click here to see more important Dotnet interview questions


Regards,


Visit Authors blog for more Most asked Dotnet interview questions



Friday, July 8, 2011

.NET Interview Questions - What is the difference between ‘DataSet’ and ‘SQLDataReader’ in ADO.NET?

In this question the interviewer is expecting two points the first point is dataset is a connect architecture and datareader is a disconnected architecture. Let’s discuss both these points in detail.

Point 1:- ‘DataSet’ is a Disconnected Architecture while ‘DataReader’ is a Connected Architecture.

In order to understand that, below is the sample code for ‘DataSet’ where you can see even after calling the “ObjConnection.Close()” the ”Foreach Loop” is still running. This indicates that the ‘DataSet’ works in Disconnected Architecture.







Similarly, below is the sample code for ‘DataReader’ where you can see that
when “ObjConnection.Close()” is called then the “While Loop” does not execute
and throws an error. This indicates that the ‘DataReader’ works only in
Connected Architecture.







Point 2:- ‘DataSet’ is an in memory representation of database by itself whereas ‘SQLDataReader’ is a flat row and column.

Dataset is an in-memory database with database, tables, columns and rows. While data reader is a flat table with just rows and columns






If you see the dataset object in your visual studio intellisense you should see the complete object hierarchy as shown in the below figure.





If you see the ‘sqldatareader’ in intellisense , its flat table with rows and columns as shown in the below image.




Please click here to see more interview questions and answers for .NET


Regards,


Visit Authors blog for more Most asked Dotnet interview questions




Wednesday, July 6, 2011

.NET and OOPS interview questions - What are abstract classes?

In the following manner we can describe abstract class: -

  • We 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.
From interview point of view, just saying using “Must Inherit” keyword is more than enough to convince that you have used abstract classes. But to clear simple fundamental let us try to understand the sample code. There are two classes one is “ClsAbstract” class and other is “ClsChild” class. “ClsAbstract” class is a abstract class as you can see the mustinherit keyword. It has one implemented method “Add” and other is abstract method, which has to be implemented by child class “Multiply Number”. In the child class, we inherit the abstract class and implement the multiply number function.
Definitely, this sample does not take out actually how things are implemented in live projects. You put all your common functionalities or half implemented functionality in parent abstract class and later let child class define the full functionality of the abstract class. Example we always use abstract class with all my SET GET properties of object in abstract class and later make specialize classes for insert, update, delete for the corresponding entity object.
Public MustInherit Class ClsAbstract
‘Use the mustinherit class to declare the class as abstract
Public Function Add(ByVal intnum1 As Integer, ByVal intnum2 As Integer) As Integer
Return intnum1 + intnum2
End Function
‘Left this second function to be completed by the inheriting class
Public MustOverride Function MultiplyNumber(ByVal intnum1 As Integer, ByVal intnum2 As Integer) As Integer
End Class
Public Class ClsChild
Inherits ClsAbstract
‘ class child overrides the Multiplynumber function
Public Overrides Function MultiplyNumber(ByVal intnum1 As Integer, ByVal intnum2 As Integer) As Integer
Return intnum1 * intnum2
End Function
End Class
Following is the output snapshot for the above code:

My attitude towards abstract class has been that i put all my common functionality in abstract class.
Following you can also view video on different types of collections available in .NET:


Please click here to see more .NET/OOPS interview questions

Regards,
Visit Authors blog for more .NET and OOPS interview questions

Tuesday, July 5, 2011

.NET and ASP.NET interview questions: State benefits and limitation of using Viewstate for state management?

Benefits of using Viewstate are as following:-

  • No server resources are required because state is in a structure in the page code.

  • Simplicity.

  • States are retained automatically.

  • The values in view state are hashed, compressed, and encoded, thus representing a higher state of security than hidden fields.

  • View state is good for caching data in Web frame configurations because the data is cached on the client.

Limitations of using Viewstate are as following: -


  • Page loading and posting performance decreases when large values are stored because view state is stored in the page.

  • Although view state stores data in a hashed format, it can still be tampered because it is stored in a hidden field on the page. The information in the hidden field can also be seen if the page output source is viewed directly, creating a potential security risk.

Below is sample code of storing values in view state.
this.ViewState["EnterTime"] = DateTime.Now.ToString();


Following is the video which demonstrates Authentication and Authorization in ASP.NET



Please click here to see more .NET/ASP.NET interview questions
Regards,

Visit Authors blog for more .NET and ASP.NET interview questions

Monday, July 4, 2011

.NET and ASP.NET interview questions: Define MVC, MVP and MVVM pattern?

Answer:

MVC, MVP and MVVM are design patterns which come under the presentation pattern category and they help to remove any kind of cluttered code in UI like manipulation of user interfaces and maintaining state. Thus keeping your UI code cleaner and better to maintain.
MVC(Model view controller) pattern divides the architecture into 3 parts model, view and controller. The first request comes to the controller and the controller then decides which view to be displayed and ties up the model with the view accordingly.
MVP (Model view presenter) has the same goals as MVC i.e. separating the UI from the model. It does the same by using a presenter class. The UI talks via an interface to the presenter class and the presenter class talks with the model.
MVVM is an architectural pattern with the focus of removing UI cluttered code. It does the same by using an extra class called as view model. MVVM is mostly suitable for Silverlight and WPF projects because of the rich bindings provided by the technologies.
Following you can see step by step video to create simple application using ASP.NET MVC template:




Please click here to see more .NET/ASP.NET interview questions

Regards,

Visit Authors blog for more .NET and ASP.NET interview questions



Saturday, July 2, 2011

C# and .NET interview questions: Explain in brief an interface?

Answer:

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.

Following code shows that one has the interface definition and other
class implements the interface. Below is the source code “IInterface” is the
interface and “ClsDosomething” implements the “IInterface”. This sample just
displays a simple message box.

Public Interface IInterFace
Sub Do Something ()
End Interface

Public Class ClsDoSomething
Implements IInterFace
Public Sub DoSomething () Implements WindowsInterFace.IInterFace.DoSomething
MsgBox (“Interface implemented”)
End Sub
End Class

After implementing the above code you will get the following output as shown:



Following you can see a simple video on boxing and unboxing:



Please click here to see more Dotnet and C# interview questions

Regards,

Visit Authors blog for more Most asked Dotnet interview questions

Friday, July 1, 2011

.NET and C# interview questions:Show how do we view an assembly in .NET?

Answer:

When coming to understand the internals, nothing can beat ILDASM. ILDASM converts the whole ‘exe’ or ‘dll’ in to IL code. To run ILDASM you have to go to ‘C:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\Bin’. Note that we had v1.1 you have to probably change it depending on the type of framework version you have.
If you run IDASM.EXE from the path you will be popped with the IDASM exe
program as shown in figure. Click on file and browse to the respective
directory for the DLL whose assembly you want to view. After you select the
DLL you will be popped with a tree view details of the DLL as shown in
figure ILDASM. On double clicking on manifest, you will be able to view
details of assembly, internal IL code etc as shown in the figure.

Note: - The version number are in the manifest itself which is defined with
the DLL or EXE thus making deployment much easier as compared to COM where
the information was stored in registry. Note the version information in Figure
Manifest view.
You can expand the tree for detail information regarding the DLL like methods, properties, functions etc.


And once you open the Manifest you will be able to see the inner details as shown in the following picture: -



Following is the video which shows that how the questions are asked C#
and .NET interviews.




Please click here to see more interview questions and answers for .NET

Regards,

Visit Authors blog for more Most asked Dotnet interview questions