Sunday, January 20, 2008

Question for Dot Net Interview (Part 2):

--* Different between Cast and Convert: x
int x = 5;
double y = x + 0.99;
int z = (int)y; //result is 5
z = Convert.ToInt32(y);//result is 6

--* What is the difference between datagrid and gridview :
1) Datagrid is used in windows application and gridview is used in web application

--* What is the difference between string class and stringbuilder class:
1) string class is immutable. Immutable is nothing but the value assigned to string cannot be changed.
2) Stringbuilder class is mutable. mutable is nothing but the value assigned to stringbuilder can be changed.
3) StringBuilder was designed with the purpose of having a mutable string
4) Strings are immutable

--* where will the JIT complier runs :
On the machine where the application is installed

--* Explain the differences between Server-side and Client-side code :
1) Server side code get executed on the web server in the response of request for any aspx page 2) client-side code get executed on the client browser or in the clients machine

--* What is Pointer:
1) C# also supports pointers in a limited extent
2) A pointer is nothing but a variable that holds the memory address of another type
3) Any of the following types may be a pointer type:
a) byte, short, ushort, int, uint, long, ulong, char, float, double, decimal, or bool.
b) Any enum type.
c) Any pointer type.
4) pointers are not allowed to point to a reference type or even to a structure type which contains a reference type
5) pointers can point to only unmanaged types which includes all basic data types, enum types, other pointer types and structs which contain only unmanaged types.
6) Declaring a Pointer type : type *variable_name;
7) Example:
int x = 100;
int *ptr = & x;.
Console.WriteLine((int)ptr) // Displays the memory address
Console.WriteLine(*ptr) // Displays the value at the memory address.
8) Example:
int* p1, p2, p3; // Ok
int *p1, *p2, *p3; // Invalid in C#
int* p :p is a pointer to an integer
int** p : p is a pointer to pointer to an integer
int*[] p : p is a single-dimensional array of pointers to integers
char* p : p is a pointer to a char
void* p : p is a pointer to an unknown type
9) Any code involving pointers requires an unsafe context
Example:
using System;

class MyClass
{
public unsafe void Method()
{
int x = 10;
int y = 20;
int *ptr1 = &x;
int *ptr2 = &y;
Console.WriteLine((int)ptr1);
Console.WriteLine((int)ptr2);
Console.WriteLine(*ptr1);
Console.WriteLine(*ptr2);
}
}

class MyClient{
public static void Main()
{
MyClass mc = new MyClass();
mc.Method();
}
}

Another Example:

using System;
class MyClass
{
public void Method()
{
unsafe
{
int x = 10;
int y = 20;
int *ptr1 = &x;
int *ptr2 = &y;
Console.WriteLine((int)ptr1);
Console.WriteLine((int)ptr2);
Console.WriteLine(*ptr1);
Console.WriteLine(*ptr2);
}
}
}

class MyClient
{
public static void Main()
{
MyClass mc = new MyClass();
mc.Method();
}
}
10) A pointer can be null.

--* Unsafe code is code which does not executed under full control of CLR

--* Which is the namespace used to write error message in event Log File?
Namespace: System.Diagnostics

--* C# dosen't support multiple-inheritance

--* Connections does Microsoft SQL Server support are:
1) Windows Authentication (via Active Directory)
2) SQL Server authentication (via Microsoft SQL Server username and password).

--* Assembly : is the smallest unit of execution in .NET framework or is the building blocks of the .NET framework.

--* Types of Assembly :
1) Private Assemblies : Assembly used within an application is
2) Public/shared Assemblies : Assembly which can be shared across applicaitons
3) Satellite Assemblies : An assembly containing localized resources for another assembly

--* Difference between Boxing and UnBoxing in C# :
1) Boxing is implicit conversion of Value Types to Reference Types
2) UnBoxing is explicit conversion of Reference Types (Object) to its Value Types

--* What property must you set, and what method must you call in your code, in order to bind the data from some data source to the Repeatercontrol?
The property is Datasource, and method is DataBind

--* What base class do all Web Forms inherit from?
System.Web.UI.Page

--* What methods are fired during the page load?
1) Init() - when the page is instantiated
2) Load() - when the page is loaded into server memory
3) PreRender() - the brief moment before the page is displayed to the user as HTML
4) Unload() - when page finishes loading

--* What data types do the RangeValidator control support?
Integer, String, and Date

--* The Global.asax (including the Global.asax.cs file) is used to implement application and session level events

--* What can be stored in Web.config file?
1. Database connections
2. Session States
3. Error Handling
4. Security

--* Name two properties common in every validation control?
1) ControlToValidate property
2) Text property or ErrorMessage

--* What is a PostBack?
The process in which a Web page sends data back to the same page on the server.

No comments: