Interview Questions Part 1 - Oracle , DotNet , SQL , UML , Javascript , AJAX
Question 1 :
What are few Oracle DDL statements or commands ?
Answer 1 :
Below are few DDL commands to create, alter, drop, and rename tables.
CREATE TABLE
- Create a table.
- Create a table based on another table by using a subquery.
- Modify table structures.
- Change column widths, change column data types, and add columns.
- Remove rows and a table structure.
- Once executed, this statement cannot be rolled back.
RENAME
Rename a table, view, sequence, or synonym.
TRUNCATE
Remove all rows from a table and release the storage space used by the table.
COMMENT
Add a comment to a table or a column.
Query the data dictionary to view the comment.
For more details refer below link :
Question 2 :
How to round off decimal to two decimal places in C# ?
Answer 2 :
There are 3 ways to round off decimal to two decimal places :
1. Use ToString()
double d = 2.445;
d.ToString("0.00")
Output : 2.45
2. Use Math.Round
double d = 2.445;
Math.Round(d, 2)
Output : 2.44
3. Create a Custom logic method like below :
N = 2.445 I want to show "2.45" only.
Step a. N*100 + 0.5 = 245
Step b. Divide System.Math.Floor(245) by 100
Step c. The result will be 2.45
Question 3 :
Which property of the image control should you use to set the descriptive text?
Answer 3:
AlternateText
Question 4 :
Your development team is working on a large scale .Net project that has multiple assemblies and code files. Before releasing the software as a Beta product, you and the team are testing classes and assemblies for bugs. Most methods have been programmed to just catch the exception without logging any information. You now want to change this so that information about the sequence of calls and the line number of the method where the exception occurred are logged.
Which property of the exception class should you use?
a. HelpLink
b. Message
c. InnerExceptionb. Message
d. StackTrace
Answer 4 : d
Question 5:
You and a group of programmers have written a new web application using Visual Studio.NET for a new client. The application tracks charity donations for a well known charity company. Due to the nature of the data it is vital that the server maintains session state even if the Web server crashes and needs to be restarted.
Which alternative is it best to use to store session state in this situation?
a. SQL Server
b. XML Configuration files
c. In-process storage
d. Session State Service
Answer 5 : a
Question 6 :
Difference between Web farm and Web Garden ?
Answer 6 :
A Web farm allows you to expand a Web Site across multiple servers whereas A Web garden allows you to expand a Web Site across multiple CPUs within a single server.
Question 7 :
State why we create custom HTTPModule ?
Answer 7 :
Custom HTTPmodule is created for:
- URL rewriting
- Compression
- Specialized authentication and authorization
- Specialized logging
Question 8 :
What is params keyword in C# ?
Answer 8 :
The params keyword lets you specify a method parameter that takes a variable number of arguments.
No additional parameters are permitted after the params keyword in a method declaration, and only one params keyword is permitted in a method declaration.
You can send a comma-separated list of arguments of the type specified in the parameter declaration, or an array of arguments of the specified type. You also can send no arguments
Example :
public static void UseParams(params int[] list)
{
for (int i = 0; i < list.Length; i++)
{
Console.Write(list[i] + " ");
}
Console.WriteLine();
}
We can call above method
Way 1 :
// You can send a comma-separated list of arguments of the specified type.
UseParams(1, 2, 3, 4);
Way 2 :
// An array argument can be passed, as long as the array
// type matches the parameter type of the method being called.
int[] myIntArray = { 5, 6, 7, 8, 9 };
UseParams(myIntArray);
Way 3:
UseParams();
Question 9 :
What is CharEnumerator in C# ?
Answer 9 :
CharEnumerator is an object in C# that can be used to enumerate through all the characters of a string.
Sample Code :
string str = "santosh";
CharEnumerator chs = str.GetEnumerator();
while(chs.MoveNext())
{
Response.Write(chs.Current);
}
Question 10 :
Difference between RegisterStartUpScript and RegisterClientScriptBlock ?
Answer 10 :
RegisterStartUpScript
This adds the javascript code at the end of the page before the closing of form tag.
RegisterClientScriptBlock
This adds the javascript code at the top of the page.
Which namespace does Cache object belong to ?Cache object belongs to System.Web.Caching namespace.
Explain WCF callback behaviour ?Call back behaviour is similar to Service behaviour . They control endpoints created on client in duplex communication.
Explain WCF Operation behaviour ?Operation behaviour are scoped at Operation level. It is used for transaction flow , serialization , parameter handling.
Explain WCF Endpoint behaviour ?Endpoint behaviour are defined at endpoint level. They are used for inspecting and taking actions on messages as they come in and out of service.
Explain WCF Service behaviour ?Service behaviour run at service level and have access to all endpoints. They control instancing and transactions. They are also used for authorization and auditing.
State different types of primary WCF behaviours ?Different types of primary behaviours are as follows :
- Service Behaviour
- Endpoint Behaviour
- Operation Behaviour
- Callback Behaviour
If set to true then IHttpHandlerFactory object ( object which calls handler ) can place handler in pool and reuse it for better performance. If set to false , new instance must be created each time handler is needed.
How to create custom synchronous HTTPHandler ?Steps to create custom synchronous HTTP Handler :
- Implement IHttpHandler interface
- Implement ProcessRequest mehtod and IsReusable property
- Register handler in Web.config
- Add file name extension mapping to ASP.NET in IIS
- ASP.NET Page Handler - handler of all .aspx pages
- Web Service Handler - handler of all .asmx
- ASP.NET User Control handler - handler of all .ascx
- Trace Handler - for trace.axd
ModuleName_OnEventName in Global.asax .
Example
Session_OnStart ( Object sender , EventArgs e ) in Global.asax defines event handler for Start event of SessionStateModule
What are default httpmodules available for all ASP.NET Applications which are declared in machine.config ?
Default modules available for all applications are :
- SessionStateModule
- OutputCacheModule
- WindowsAuthenticationModule
- FormsAuthenticationModule
- PassportAuthenticationModule
- UrlAuthorizationModule
- FileAuthorizationModule
- Implement IHttpModule Interface
- Handle Init Method and register events one needs
- Handle the events
- Implement Dispose if one has to perform cleanup . This is optional
- Register module in Web.config
modifier return type this [argument list]
{
get
{
// Get codes goes here
}
set
{
// Set codes goes here
}
}
Where the modifier can be private, public, protected or internal. The return type can be any valid C# types. The 'this' is a special keyword in C# to indicate the object of the current class. The formal-argument-list specifies the parameters of the indexer. The formal parameter list of an indexer corresponds to that of a method, except that at least one parameter must be specified, and that the ref and out parameter modifiers are not permitted. Remember that indexers in C# must have at least one parameter. Other wise the compiler will generate a compilation error.
Difference between indexer and property ?
1. An indexer is identified by it's signature. But a property is identified it's name.
2. An indexer is always an instance member, but a property can be static also.
3. An indexer is accessed through an element access. But a property is through a member access.
How Do I Release COM objects?Runtime Callable Wrapper is managed hence its lifetime is controlled by Common Language Runtime. The COM component is freed from memory when the garbage collector calls the Finalize() method on RCW. Internally, RCW calls Release() of IUknown interface on the COM object.
To explicitly remove COM objects from memory, invoke the static method on Marshal class in System.Runtime.InteropServices namespace:
using System.Runtime.InteropServices;
Marshal.ReleaseComObject(myAuthorRCW);
State some important things in .NET 3.0.NET 3.0 consists of :
- Windows Communication Foundation ( WCF )
- Windows Presentation Foundation ( WPF )
- Windows Workflow Foundation ( WF )
- Windows Cardspace
State whether below class relationship is correct or not . If not why ?
class A: B {}
class B: C {}
class C: A {}
Answer :
Above releationship is incorrect as it has circular relationship. This would result in compile-time error.
How can Validation Summary show validation errors in Message Box instead of Web page ?Set ShowMessageBox property to true and ShowSummary=false for ValidationSummary control.
State two importanrt properties of System.Exception Class ?Two properties of System.Exception Class are :
- Message
- InnerException
using System;
delegate void DelMethod(int x); // This is the delegate declaration
// Example is Class containing static method and instance method to be instantiated
class Example
{
public static void StaticMethod(int i) {
Console.WriteLine("M1: " + i);
}
public void InstanceMethod(int i) {
Console.WriteLine("M3: " + i);
}
}
// Below class contains code to instantiate and invoke static and instance method using delegates
class Test
{
static void Main() {
DelMethod cd1 = new DelMethod (Example.StaticMethod); // Instantiate Static Method delegate
cd1(-1); // Invoke Static Method
Example c = new Example ();
DelMethod cd2 = new DelMethod (c.InstanceMethod); // Instantiate InstanceMethod delegate
cd2(5); // Invoke Instance Method
}
}
What are different types of remotable objects ?Two types of remotable objects :
- Marshal-by-value objects
- Marshal-by-reference objects
- Machine configuration file
- Application configuration file
- Security configuration file
- Static and Dynamic assemblies
- Private and Shared assemblies
- Single file and Multiple file assemblies
What does assembly version consists of ?Assembly version consists of four parts i.e. major version.minor version.build number.revision
What is computed column ?Computed Column is virtual column in table whose value is computed at runtime.The values are not stored in table but computed by the expression that defines column.
State different types of indexesThere are two types of indexes :
- Clustered Index
- Non Clustered Index
What global variable is used to return number of rows returned by last Transact-SQL ?@@ROWCOUNT is global variable used to return number of rows returned by last Transact-SQL.
Question : Two TSQL statements are executed in below order :
DELETE FROM Employee where EmpID=10
UPDATE Employee set EmpSal = 10000 where EmpID = 15
SELECT @@ERROR
A. @@ERROR will store Error Number of Delete statement
B. @@ERROR will store Error Number of Update statement
Answer : B is correct option
Hint : @@ERROR contains error number of last TSQL statement executed.
@@ERROR has value of 0. What does it mean ?@@ERROR with value of 0 indicates no error. @@ERROR with non zero value indicates error.
What global variable is used to return error number of last Transact-SQL ?@@ERROR is a global variable used to return error number of last T-SQL.
Which interfaces to use or implement when sorting custom arrays ?Sorting in Custom Arrays can be acheived using one of following interfaces :
- IComparable
- IComparer
- DATE - occupies 3 bytes . Has accuracy of 1 day . Data stored in 'YYYY-MM-DD' format
- TIME - occupies 3 to 5 bytes . Has accuracy of 100 nanoseconds. Data stored in 'hh:mm:ss.nnnnnnn' format.
- DATETIME2 - occupies 6 to 8 bytes . Has accuracy of 100 nanoseconds. Data stored in 'YYYY-MM-DD hh:mm:ss.nnnnnnn' format.
- DATETIMEOFFSET - occupies 8 to 10 bytes . Has accuracy of 100 nanoseconds. Data stored in 'YYYY-MM-DD hh:mm:ss.nnnnnnn [+|-]hh:mm' format. The DATETIMEOFFSET data type is similar to DATETIME2 but has time zone component extra.
How to get distinct records using LINQ ?Distinct records can be obtained using Distinct() method. Please refer below code for more details :
Problem : Get Unique or Distinct First Name from Employee table
Solution :
var employeeDistinct= (from emp in Employee
select emp.FirstName).Distinct();
What is ANSI_PADDING ?ANSI_PADDING can be set ON or OFF. It controls the way column stores values shorter than the defined size of the column, and the way the column stores values that have trailing blanks in char, varchar, binary, and varbinary data.
Transact SQL Statement to set it ON
SET ANSI_PADDING ON
Transact SQL Statement to set it OFF
SET ANSI_PADDING OFF
ANSI_PADDING setting is ON :
char(n) and binary(n) - Pads value with trailing blanks for char columns and with trailing zeros for binary columns to the length of column.
varchar(n) or varbinary(n) - Trailing blanks in varchar are not trimmed . Trailing zeroes in varbinary are not trimmed. Does not pads trailing blanks or zeroes to the length of column.
ANSI_PADDING setting is OFF :
char(n) and binary(n) - Pads value with trailing blanks for char columns and with trailing zeros for binary columns to the length of column.
varchar(n) or varbinary(n) - Trailing blanks in varchar are trimmed . Trailing zeroes in varbinary are trimmed. Does not pads trailing blanks or zeroes to the length of column.
What is extent in SQL Server ?Extents are basic unit in which space is allocated to tables and indexes. Extent is eight contiguous pages i.e 64 KB.
What is fundamental unit of storage in SQL Server ?Page
Different types of relationship in Class diagram ?Different types of relationship in Class diagram :
- Generalization
- Aggregation
- Composition
- Select
- Insert
- Update
- Delete
- Grant
- Revoke
- Deny
- Create
- Alter
- Drop
- Data Definition Language ( DDL )
- Data Control Language ( DCL )
- Data Manipulation Language ( DML )
- Logins
- Users
- Roles
- Groups
- NO ACTION specifies that the deletion fails with an error.
- CASCADE specifies that all the rows with foreign keys pointing to the deleted row are also deleted.
- SET NULL specifies that all rows with foreign keys pointing to the deleted row are set to NULL.
- SET DEFAULT specifies that all rows with foreign keys pointing to the deleted row are set to their default value.
- NOT NULL constraint
- Check constraint
- UNIQUE constraint
- PRIMARY KEY constraint
- FOREIGN KEY constraint
SQL Constraints are used to enforce integrity of database.
Difference between Unicode and non-Unicode datatype ?
Unicode datatypes are nchar, nvarchar, and ntext .
Non-Unicode datatypes are char, varchar, and text .
Difference between Unicode and non-Unicode datatype are :
- Unicode supports a wider range of characters.
- More space is needed to store Unicode characters.
- The maximum size of nchar and nvarchar columns is 4,000 characters, not 8,000 characters like char and varchar.
- Unicode constants are specified with a leading N: N'A Unicode string'.
- All Unicode data uses the same Unicode code page. Collations do not control the code page used for Unicode columns, only attributes such as comparison rules and case sensitivity.
Collations control physical storage of characters strings in SQL Server. Collation specifies bit patterns that represent each character and the rules by which characters are sorted and compared.
Collation specifies three properties:
- Sort order to use for Unicode data types ( nchar , nvarchar and ntext )
- Sort order to use for non-Unicode data types ( char , varchar and text )
- Code page to store non-Unicode character data
- Table
- Data Type
- View
- Stored procedure
- Function
- Index
- Constraint
- Rule
- Default
- Trigger
• The address specifies where the messages can be sent (or where the service lives).
• The binding describes how to send the messages.
• The contract describes what the messages should contain.
Which namespace does WCF belong to ?
Answer : WCF belongs to System.ServiceModel
State ways to host WCF Service ?WCF Service can be hosted in following four ways :
- Internet Information Server ( IIS )
- Windows Activation Service ( WAS )
- Self hosting
- Managed Windows Service
Please refer below links for more information :
Hosting WCF Service
What is Type Library Importer (Tlbimp.exe) ?The Type Library Importer or Tlbimp.exe is used to convert type definitions within COM component to equivalent definitions in CLR assembly. The output of Tlbimp.exe is a binary file (an assembly) that contains runtime metadata for the types defined within the original type library. You can examine this file with tools such as Ildasm.exe.Santosh Singhhttp://www.blogger.com/profile/0455433154258677971902010-05-20T10:50:46.415-07:00How to change size of array ?Size of array can be changed using Array.Resize Method. Array.Resize Method can be used to increase or reduce size.
Syntax :
Array.Resize
Example :
int[] arrayInt = new int[10];
Resize the above array to new size 20
Array.Resize
Which namespace does Trace and Debug class belong to ?Trace and Debug class belongs to System.diagonastics
What are different types of WCF ContractsThere are five types of contracts :
- Service Contract
- Operation Contract
- Data Contract
- Message Contract
- Fault Contract
Please refer below links for more details :
http://www.alltechnicalfaqs.com/2010/05/wcf-contracts.html
How to sort array of primitive types in ascending and descending order ?We can sort array of primitive types using Array.Sort() and Array.Reverse() in ascending and descending order
Example :
// sort int array in ascending order
int[] intArray = new int[5] { 8, 10, 2, 6, 9 };
Array.Sort(intArray);
// write array
foreach (int i in intArray) Console.Write(i + " "); // output: 2 6 8 9 10
// sort int array in descending order
int[] intArray = new int[5] { 8, 10, 2, 6, 9 };
Array.Sort(intArray);
Array.Reverse(intArray);
// write array
foreach (int i in intArray) Console.Write(i + " "); // output: 10 9 8 6 2
How to convert string to Enum ?Please refer below example for answer :
public enum MonthEnum
{
January = 1,
February = 2,
March = 3,
April = 4,
May = 5,
June = 6,
July = 7,
August = 8,
September = 9,
October = 10,
November = 11,
December =12
}
To Convert string value to enum instance use below :
Month may= (MonthEnum)Enum.Parse(typeof(MonthEnum), "May");
How to get first record using LINQ ?First record of collection can be obtained using First() method .
Example :
Code :
string[] strings = { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" };
string startsWithO = strings.First(s => s[0] == 'o');
Console.WriteLine("A string starting with 'o': {0}", startsWithO);
Output :
A string starting with 'o': one
How to convert IEnumerable collection to IQueryable collection ?IEnumerable collection can be converted to IQueryable collection using AsQueryable method.
Example :
Object arrSearch is of IEnumerable
To convert into IQueryable use below :
IQueryable
- Publisher- Database server whose data has to be replicated
- Subscriber - Database servers that get data from publishers
<><><><><><><><><><><><>
Sl No | Feature | Repeater | DataList | DataGrid | |
1. | Default Appearance | No Default Appearance | Table | Grid |
Pass the parameter’s value as DBNull.Value from code-behind.
Difference between XML DOM and Simple API for XML
- XML DOM loads the entire xml document into memory whereas Simple API for XML ( SAX ) does not load entire xml document into memory
- XML DOM is used when you want to modify xml document and perform complex searches whereas SAX is not used when you want to modify xml document and perform complex searches
Question :
Name few C# 3.0 enhancements ?
Answer :
The C# 3.0 language enhancements are as follows:
- Implicitly typed local variables
- Implicitly typed arrays
- Object initializers
- Collection initializers
- Auto-implemented properties
- Extension methods
- Lambda expressions
- Expression trees
- Query expressions
- Anonymous types
Class Child inherits from Class Parent and has mehtod ShowVirtualOverride() and ShowNew() methods.
Please see the code snippet below and answer questions below:
class Parent
{
public virtual void ShowVirtualOverride()
{
Console.WriteLine("ParentVirtual");
}
public virtual void ShowNew()
{
Console.WriteLine("ParentNew");
}
}
class Child : Parent
{
public override void ShowVirtualOverride()
{
Console.WriteLine("ChildVirtual");
}
public new void ShowNew()
{
Console.WriteLine("ChildNew");
}
}
Question 1:
What is output of below code :
Parent objA = new Parent();
objA.ShowVirtualOverride();
objA.ShowNew();
Answer 1:
Output is below :
ParentVirtual
ParentNew
Question 2:
What is output of below code :
Parent objB = new Clild();
objB.ShowVirtualOverride();
objB.ShowNew();
Answer 2:
Output is below :
ChildVirtual
ParentNew
Question 3:
What is output of below code :
Child objC = new Child();
objC.ShowVirtualOverride();
objC.ShowNew();
Answer 3:
Output is below :
ChildVirtual
ChildNew
Question 4:
What is output of below code :
Child objD = new Parent();
objD.ShowVirtualOverride();
objD.ShowNew();
Answer 4:
This gives compilation error
Difference between stored procedure and functionStored Procedure vs Function
- Stored procedure cannot be executed using SQL Select command whereas Function (UDF) can be executed using SQL Select command. Stored Procedure can be executed using execute command i.e EXEC or EXECUTE
- Stored Procedure can return zero to n values whereas Function can return one value that is mandatory
- Stored Procedure can have input and output parameters whereas Function can have only input parameters.
- Stored Procedure can call functions whereas Function cannot call stored procedures.
- Stored Procedure exception handling can be done by try-catch block whereas Function exception handling cannot be done by try-catch block.
- Stored Procedure can't return a table variable although it can create a table while Function returns table variables.
- Stored Procedure can change the server environment or your operating system environment, while Function can change the server environment or your operating system environment
Question : Which shells support command-line editing in vi mode and emacs mode?
Answer : Following shells support editing in vi and emacs mode :
- Korn
- Bash
- TC
Answer : semi colon is used to seperate commands i.e ;
Question : What does the following code do? ls rep|| mkdir rep
Answer : This would run the mkdir command if the ls command doesn't execute successfully
What is difference between Dataset and DataReader ?
- Database Connection - Datereader requires an open database connection whereas Dataset does not require an open database connection
- Namespace - Datereader belongs to System.Data.SqlClient or System.Data.OleDB whereas Dataset belongs to System.Data
- Record Set - Datereader is forward only and read only whereas Dataset is not forward only and read only
- Data Source - Datereader can get data from managed data provider. Data cannot be loaded manually whereas Dataset can get data from managed data provider .Data can be loaded manually by XML etc.
- Performance - DataReader has faster retrival and better performance then Dataset
- Connection Pooling : Connection between Web Application and SQL Server is expnsive. So, connection pooling can improve performance.To use connection pooling, use the same connection string. Also , open the connection, do the work and then close the connection.
- Paged Data Access : Datagrid with paging would show fixed number of records. Suppose a Datagrid is bound with 100000 records but if page size is 25 , then Datgrid would display only 25 records out 100000 records. Data layer has to fetch all 100000 records and bind to Datgrid hence performance would be bad. So , Paged Data Access would really improve performance wherein you fetch only fixed number of records to be shown in Datagrid using stored procedure.
- Caching : Caching data would improve performance. Data is used more than once is good situation to use Caching. Also, data is general and not user or request specific is an ideal situation for Caching
- ViewSate : Viewstate is used to store state data in hidden field in page.When the page is posted back to the server, the server can parse, validate, and apply this view state data back to the page's tree of controls. There are a number of drawbacks to the use of view state, however. First of all, it increases the total payload of the page. There is also an additional overhead incurred when serializing or deserializing view state data that is posted back to the server. Lastly, view state increases the memory allocations on the server.So diabling View State will improve performanca of page.Within a control, you simply set the EnableViewState property to false, or you can set it globally within the page using this setting.
- Return Muliple RecordSet : Returning multiple recordset will improve performance by reducing time spent and resource spent to cumminicate with SQL
ASP.NET impersonation is disabled by default. If impersonation is enabled for an ASP.NET application, that application runs in the context of the identity whose access token IIS passes to ASP.NET.
<configuration>
<system.web>
<identity impersonate="true">
</system.web>
</configuration>
or<identity impersonate="true" password="********" username="testDomain\Santosh">
What is authorization and how ASP.NET authorization works ?Authorization is used to determine whether user has access to resource or not.
There are two ways to authorize a resource :
File authorization : is performed by the FileAuthorizationModule. It checks the access control list (ACL) of the .aspx or .asmx handler file to determine whether a user should have access to the file.
URL authorization : is performed by the UrlAuthorizationModule, which maps users and roles to URLs in ASP.NET applications. This module can be used to selectively allow or deny access to arbitrary parts of an application (typically directories) for specific users or roles.
<[allow/deny] users roles verbs />
What is authentication and different types of ASP.NET authentication ?Authentication is process of obtaining credentials such as username and password and validating the credentials.
- Windows authentication
- Form authentication
- Passport authentication
The important properties and methods common to all validation controls are as follows:
- ControlToValidate - Specifies which control to be validated
- IsValid - Boolean value stating whether control to be validated is valid or not
- ErrorMessage - Error message which will be displayed in Validation Summary
- Validate - Method to validate and set IsValid property
- Display - This specifies how the error message is shown.
- None (The validation message is never displayed.)
- Static (Space for the validation message is allocated in the page layout.)
- Dynamic (Space for the validation message is dynamically added to the page if validation fails.)
Different validation controls in ASP.NET are as follows :
- RequiredFieldValidator
- CompareValidator
- RangeValidator
- RegularExpressionValidator
- CustomValidator
- ValidationSummay
Various Page lifecycle events are listed below :
- PreInit - Check IsPostBack Property , Create dynamic controls , Set Master page , Theme and Profile properties dynamically.
- Init - Read and Initialize control properties
- InitComplete
- PreLoad - Use this event if one wants to do something before Page or Control load
- Load - Set Control properties etc.
- Control Events - Handle Events specific to controls like button , link etc
- LoadComplete
- PreRender - occurs for each control on the page. Use the event to make final changes to the contents of the page or its controls.
- SaveStateComplete - perform tasks that require view state to be saved, but that do not make any changes to controls.
- Render - calls this method on each control.
- Unload - occurs for each control and then for the page.
Ease of Creation : User Control is easy to create whereas Custom Control is complex to create
Good For : User Control good for static content whereas Custom Control good for dynamic content
Usage : User Control need to create seperate copy for each application . Custom control , one single copy is required and placed in GAC
Toolbox : User control cannot be added to Visual Studio toolbox . Custom control can be added to Visaul Studio Toolbox
What are the different IIS authentication modes ?
IIS provides a variety of authentication schemes:
• Basic - Client supplies username and password.Username and password transmitted in clear text
• Digest - Uses MD5 algorithm
• Integrated Windows authentication - can use either NTLM or Kerberos V5 authentication and only works with Internet Explorer 2.0 and later
Difference Between String and String Builder ?
String is collection of char objects . String is immutable ( read only ) since its value cannot be modified once it is created . It belongs to System namespace .
String concatenation always creates a new object from existing string and new data
StringBuilder is mutable string of characters . It belongs to System.Text namespace. StringBuilder does not creates a new object
What are various OOPs concept that C# supports?OOPs concepts that C# supports are :
- Abstraction : is a process that involves identifying the crucial behavior of an object and eliminating irrelevant and tedious details. Suppose you have to design a software to calculate area and perimeter . So you have a abstract class for Shape with two behaviours CalculateArea and ClaculatePerimeter as behaviour. So all classes i.e Square, Rectangle etc has to inherit and forced to implement these two behaviours.
- Encapsulation : is often referred to as information hiding.Encapsulation makes it possible to separate an object’s implementation from its behavior—to restrict access to its internal data. This restriction allows certain details of an object’s behavior to be hidden. It allows us to create a “black box” and protects an object’s internal state from corruption by its clients.
- Inheritance : enables to create a new class that reuses , extends , modifies the behaviour of another class . The class whose members and behaviours are inherited is known as base class . The class which inherits another class is known as derived class.
- Polymorphism refers to the ability to assume different forms.
public class Operation
{
public int Add ( int a , int b )
{
return (a+b);
}
}
We have to call above method using delegate
Steps below :
- Declare a delegate : public delegate int DelAdd ( int a , int b );
- Instantiate a delegate : Operation obj = new Operation() ; DelAdd objDel = new DelAdd(obj.Add);
- Call a delegate : objDel(1,2);
What is multicast delegate ?
Multicast delegate contains references to more than one function . Use + operator to add a delegate component to multicast delegate . - operator is used to remove delegate component from multicast delegate
Explain Covariance and Contravariance in Delegates ?
Covariance permits a method to have a more derived return type than what is defined in the delegate.
Contravariance permits a method with parameter types that are less derived than in the delegate type.
Comparison of Usage of Delegate and Interface ?
Use a delegate when:
- An eventing design pattern is used. • It is desirable to encapsulate a static method.
- The caller has no need access other properties, methods, or interfaces on the object implementing the method.
- Easy composition is desired
- A class may need more than one implementation of the method
- There are a group of related methods that may be called.
- A class only needs one implementation of the method.
- The class using the interface will want to cast that interface to other interface or class types.
- The method being implemented is linked to the type or identity of the class: for example, comparison methods.
New features C# 2.0 are:
- Generics - The .NET Framework class library contains several new generic collection classes in the System.Collections.Generic namespace. These should be used whenever possible in place of classes such as ArrayList in the System.Collections namespace.
- Iterators - make it easier to dictate how a foreach loop will iterate over a collection's contents.The yield keyword is used to specify the value, or values, returned. When the yield return statement is reached, the current location is stored. Execution is restarted from this location the next time the iterator is called. You can use more than one yield statement in the same iterator
- Partial Classes - Partial type definitions allow a single type, such as a class, to be split into multiple files. The Visual Studio designer uses this feature to separate its generated code from user code.
- Nullable Types - Nullable types allow a variable to contain a value that is undefined. Nullable types are useful when working with databases and other data structures that may contain elements that contain no specific values.
- Anonymous Methods - It is now possible to pass a block of code as a parameter. Anywhere a delegate is expected, a code block can be used instead: there is no need to define a new method.
- Namespace alias qualifier - The namespace alias qualifier (::) provides more control over accessing namespace members. The global :: alias allows access the root namespace that may be hidden by an entity in your code.
- Static Classes - Static classes are a safe and convenient way of declaring a class containing static methods that cannot be instantiated. In C# version 1.2 you would have defined the class constructor as private to prevent the class being instantiated.
- External Assembly Alias - Reference different versions of the same component contained in the same assembly with this expanded use of the extern keyword.
- Property Accessor Accessibility - It is now possible to define different levels of accessibility for the get and set accessors on properties.
- Covariance and Contravariance in Delegates -The method passed to a delegate may now have greater flexibility in its return type and parameters.
Compare Interface with Abstract Class
Explain features of Abstract method ?Features of abstract method is below :
- Cannot be declared in non abstract class . Can only be declared in abstract class.
- Cannot have actual implementation or method body
- Cannot have static or virtual modifier in abstract method declaration
Abstract class has following features :
- cannot be instantiated
- contain abstact methods and properties
- cannot modify abstract class with sealed modifier
- non abstract class which inherits from abstract class must implement inherited abstract methods and properties
- An abstract class that implements an interface might map the interface methods onto abstract methods
{
abstract public int Perimeter();
}
{
int x;
public override int Perimeter()
{
return 4x;
}
}
Difference between throw and throw exception ?
throw would keep the stack trace intact whereas throw ex will clear the stack trace so point of exception will be line throw ex and not the actual line where the error occured
What are different access modifiers/specifiers in C# ?
Different access modifiers/specifiers in C# :
- Public - Any class or assembly can access
- Protected - Access is limited to the containing class or classes derived from the containing class
- Internal - Access is limited to the current assembly.
- Protected Internal - Access is limited to the current assembly or types derived from the containing class.
- Private - Access is limited to the containing class
Isolation level in SQL Server are as follows :
- Read Uncommitted - Lowest level of isolation . Uncommitted data can be read . Hence we will have Dirty Read , Nonrepeatable read and Phantom record. Shared and exclusive locks are not honoured .
- Read Committed - This is SQL's default isolation level . Uncommitted data cannot be read. It allows inserts and deletes. Shared locks are held hence dirty read is avoided but we still have Nonrepeatable read and Phantom record
- Repeatable Read - It prevents data updation . Locks are placed on the data , preventing other users from updating the data. Prevents non-repeatable reads but phantom rows are still possible.
- Serializable - Highest level of isolation . Prevents other users from updating or inserting rows into the dataset until the transaction is complete . We don't have Dirty Read , Nonrepeatable read and Phantom record
What is normalization ?
Normalization is a method to seperate data into multiple tables and relate these multiple tables. Some benefits of normalized database :
1) Removes redundancy of data
2) Faster sorting
What is Class Diagram ?
Class Diagram is static diagram which contains following : Classess, Attributes and Relationship
Class is represented by box containg three compartment which contain Class name, attributes ( ie.properties ) and behaviours ( i.e methods ). Access modifiers are represented in following way in Class diagram :
- "+" for public
- "#" for protected
- "?" for private
Different types of diagrams in UML :
- UseCase diagram
- Class diagram
- Object diagram
- State diagram
- Sequence diagram
- Collaboration diagram
- Activity diagram
- Deployment diagram
- Component diagram
What are benefits and drawback of AJAX ?Benefits of Ajax :
- Improved user experience
- Asynchronous processing
- Reduced server hits and network load
- Platform and architecture neutrality
- Multibrowser support
- Faster page renders and improved response times
Drawback of Ajax :
- Massive usage and dependency on JavaScript
1) Protocol : Webservice can be accessed over HTTP protocol . Remoting can be accessed over any protocol (including TCP, HTTP, SMTP etc)
2) Interoperability : Webservices support interoperability across platforms, and are ideal for heterogeneous environments. Remoting requires the client be built using .NET, enforcing homogenous environment.
3) Ease of programming : Webservice is easy to create and deploy . Remoting is complex to create
4) State Management : Webservices are stateless . Remoting support for both stateful and stateless environments through Singleton and SingleCall objects
What is WCF ?
WCF stands for Windows Communication Foundation. WCF was introduced with .NET Framework 3.0. It provides combined features of Web Services , Remoting , MSMQ and COM+ . It is used for building and deploying network distributed services
What is Abstract Factory Pattern ?
Abstract Factory Pattern is type of Creational pattern . This is used to create objects of related class without specify concrete class.
Abstract Factory has :
1) Abstarct Factory - declares an interface for operations that create abstract product objects.
2) Concrete Factory - implements the operations to create concrete product objects.
3) Abstract Product - declares an interface for a type of product object.
4) Concrete Product - defines a product object to be created by the corresponding concrete factory. It implements the Abstract Product interface.
5) Client - uses only interfaces declared by Abstract Factory and Abstract Product classes.
What is singleton design pattern ?Singleton design pattern is type of Creational Design pattern . It creates a single instance object which caters to all the clients.
Singleton Design pattern has :
- It has private constructor so that instance of class cannot be created anywhere but inside its own methods.
- It has static read only member so that instance is created only once .
- It has an instance property to return singleton object instance
public sealed class Singleton
{
// private constructor
private Singleton()
{
}
// static readonly member
static readonly Singleton instance = new Sinleton();
// static instance property
public static Singleton Instance
{
get { return instance ; }
}
}
What is difference between Control Flow and Data Flow in SSIS ?
Difference between Control Flow and Data Flow in SSIS are as follows :
- The smallest unit in Control Flow is task whereas smallest unit in Data Flow is component
- In Control FLow , Tasks require completion (success, failure or completion) before moving to next task. In Data Flow , one component will not wait for other component to finish, all of them will work together in processing and managing data in streaming way.
SSRS stands for SQL Server Reporting Services . SSRS is server based reporting platform. It provides reporting functionality from different datasourses. SSRS enables creation , management and delivery of reports.
Explain about software estimation ?
Software estimation is used to estimate time and resource required for a particular project.
There are three types of estimation :
- Ballpark estimates or order of magnitude: This estimate would be two to four times actual value ideally.
- Rough estimates: This estimate would be closer to the actual value. Ideally it will be about 50% to 100% off the actual value. It is used when needs are well understood
- Fair estimates: This is a very good estimate. Ideally it will be about 25% to 50% off the actual value. Fair estimate is used in maintainence projects where you know what needs to be done and you have already done it.
Break project into number of tasks
Evaluate each task based on complexity i.e ( Low , Medium , High ) and size of work ( Small, Medium, Large)
Once this done , then estimate time for each task based on complexity and size of work. For example , Low complexity and small sized work would require a weeks time.
What happens to the objects which survive a garbage collection?
New objects are created in generation 0. Those which survive first collection are moved to the generation 1, after second collection the survived objects are moved to the generation 2 and stay in that generation since the max number of generation supported by CLR is 2. In other words, the overall number of generations supported is 3 (0, 1 and2)
Compare Application domain and Thread ?
Application domain vs Thread
Application domain is isolation boundary for security , reliability , versioning and unloading of managed code . Thread are operating system construct to execute managed code ( used by CLR ) .
Managed code is loaded in application domain and run by thread.
An application domain may contain zero or one or more threads.
What is JIT Compiler ?JIT stands for Just in Time . JIT compiler converts MSIL code to runtime or machine code. There are three basic types of JIT compiler :
- Pre JIT
- Econo JIT
- Normal JIT
MSIL stands for Microsoft Intermediate language . All .NET Code is compiled into MSIL Code . The MSIL Code is converted to machine code at runtime by JIT Compiler
What is relationship between CTS and CLS ?
CTS defines the rules the CLR follows to declare, use and manage types. CTS enables cross-language integration, type safety, and high-performance code execution.
CLS rules that governs the interoperation of types in different programming languages. Targeting the CLS is an excellent way to ensure cross-language interoperation.
What is CLS ?
CLS stands for Common Language Specification.It is subset of CTS . It defines rules that governs the interoperability of langaunages. All .NET compliant languages should adhere to CLS .
What is CTS ?
CTS stands for Common Type System. It helps in language interoperability. It defines how to define and use types. Interger is VB.NET and int is C# is coverted to System.Int32.
What are few important components of .NET Framework ?
Two important component of .NET Framework :
- CLR
- .NET Class Libraries
CLR stands for Common Language Runtime. CLR provides the execution environment for .NET Code. CLR provides following features :
- Garbage Collection
- Memory Management
- Code Access Security
- Code Verification etc
This post is simple but great! I recommend it for all software employees.
ReplyDeleteThanks . Please provide any interview questions you want us to answer
DeleteThe combined Questions
ReplyDeletewill be mostly asking for the freshers as they will check the basics for all the languages.Even i faced this many time so i know better!