Search This Blog

Thursday 24 July 2014

Exp Interview questions with Answers 1-36



1.What is the difference between Abstraction and Encapsulation?

• Abstraction means to show only the necessary details to the client of the object.

• Abstraction is about paying attention to the details that are relevant and ignoring the rest.

• It refers to act of representing essential features without including background details / explanations

ex: 

• Do you know the inner details of the Monitor of your PC?

What happen when you switch ON Monitor? No Right, Important thing for you is weather Monitor is ON or NOT.

----------------------------------------------------------------

• Encapsulation is a process of hiding all the internal details of an object from the outside world.

• Encapsulation is the ability to hide its data and methods from outside the world and only expose data and methods that are required

ex:

• Let's say you have an object named Bike and this object has a method named start(). 

When you create an instance of a Bike object and call its start() method you are not worried about what happens 

to accomplish this, you just want to make sure the state of the bike is changed to 'running' afterwards.

This kind of behavior hiding is encapsulation and it makes programming much easier.


2.What is interface class vs Abstract class? 

Abstract class:

• It is a class that cannot be instantiated, it exists extensively for inheritance and it must be inherited.

• Abstract classes cannot be used to instantiate objects; because abstract classes are incomplete

• Abstract classes may contain only definition of the properties or methods.

• Derived classes that inherit the abstract class needs to implements it's properties or methods.

• An abstract class is essentially a blueprint for a class without any implementation.

• An abstract class is a class that must be inherited and have the methods overridden.

 An abstract class cannot be a sealed class.

 An abstract method cannot be private.

 An abstract member cannot be static.

• An abstract method cannot have the modifier virtual. Because an abstract method is implicitly virtual.

• The access modifier of the abstract method should be same in both the abstract class and its derived class. 

If you declare an abstract method as protected, it should be protected in its derived class. Otherwise, 

the compiler will raise an error.

Interface: 

• An interface looks like a class, but has no implementation.

• An interface is a named set of method signatures.

• An Interface is a reference type and it contains only abstract members.

• An interface is an array of related function that must be implemented in derived type.

• Members of an interface are implicitly public & abstract.

• It can contain definitions of events, indexers, methods parameter less and parameter properties.

• The interface can't contain constants, data fields, constructors, destructors and static members.

• All the member declarations inside interface are implicitly public. 

• Interfaces are great for putting together plug-n-play like architectures where components can be interchanged at will. Since all interchangeable components implement the same interface, they can be used without any extra programming.

3.What is cache in Asp.net?

• Caching is a technique where we can store frequently used data and Web pages are stored temporarily 

on local hard disks for later retrieval.

• This technique improves the access time when multiple users access a Web site simultaneously 

or a single user accesses a Web site multiple times.

• Caching can occur on the client (browser caching), on a server between the client and 

the Web server (proxy / Reverse Proxy Caching), and on the Web server itself (page or data caching).

• We can classified caching location in 4 way

 Client Caching (Client Browser)

 Proxy Caching (In between Client and Server)

 Reverse Proxy Caching (In between Client and Server)

 Web Server Caching (Data Caching/ Page Output Caching)


types:

• Page Output caching [Output caching ] - 

Is used to fetch information or data at page level. It is best used when the site is mainly static.

Used by declaring the output page directive

• Fragment caching [Output caching ] - 

Is used to cache the structure level information. It is used when parts of pages change. 

For example: user control

• Data Caching - 

Is used to fetch the information of an application quickly based on the requirements.



4.What is Viewstate?(All state management techniques)

• It is a built-in structure for automatically retaining values amongst multiple requests for the same page.

• The viewstate is internally maintained as a hidden field on the page but is hashed.

• View State is used to retain the state of server-side objects between post backs.

• Controls perform well - Label, TextBox, CheckBox, RadioButton, and HyperLink

• Controls perform less - DropDownList, ListBox, DataGrid, and DataList because of size and large data.

• Making roundtrips to the server.

• Item stored in Viewstate exist for the life of the current page. This includes PostBack (to the same page).

adv:

• No server resources are required.

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

• It is good for caching data in Web frame configurations because the data is cached on the client

• Simple to use

·        


5. Differnce between Method over loading and overriding?

# Method overloading means having two or more methods with the same name but with different signatures

Method overriding means having two or more methods with the same name , 

same signature but with different implementation.

(Base class and Child class implementation of a method with same name and signature)

# Code refining Technique---Code Replacement Technique


6.Session vs Application object?

Client – Side State Management

View State – Asp.Net uses View State to track the values in the Controls. You can add custom values to the view state. It is used by the Asp.net page framework to automatically save the values of the page and of each control just prior to rendering to the page. When the page is posted, one of the first tasks performed by page processing is to restore view state.

Control State – If you create a custom control that requires view state to work properly, you should use control state to ensure other developers don’t break your control by disabling view state.

Hidden fields – Like view state, hidden fields store data in an HTML form without displaying it in the user's browser. The data is available only when the form is processed.

Cookies – Cookies store a value in the user's browser that the browser sends with every page request to the same server. Cookies are the best way to store state data that must be available for multiple Web pages on a web site.

Query Strings - Query strings store values in the URL that are visible to the user. Use query strings when you want a user to be able to e-mail or instant message state data with a URL.

Server – Side State Management

Application State - Application State information is available to all pages, regardless of which user requests a page.

Session State –Information is available to all pages opened by a user during a single visit.

Both application state and session state information is lost when the application restarts. To persist user data between application restarts, you can store it using profile properties.




7.Example program for Absraction and interface.?

Abstract Class
Interface
Cannot be instantiated, means one cannot make a object of this class.
We can only define method definition and no implementation.
Access modifiers are allowed
Access modifiers are not allowed
Some methods can be concrete
All methods are abstract
A class can inherit only one abstract class
A class can inherit many interfaces.
Can have any access modifiers
By default its public static final
Can have constructor and destructor
Cannot have constructor and destructor
Only one abstract class can be derived
Class can have multiple interfaces
Requires more time to find actual method in class
Faster
Abstract class provides 0 to 100% generalization
Interface provides 100% generalization
It provides both generalization and specialization
Interface provides only Generalization

8.String vs string builder?

String:

#String objects are immutable, which means that once they are created they cannot be changed.

When we use one of the methods of the String class, we create a new string object.

#Here concatenation is used to combine two strings.

#String object is used to concatenate two strings

#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

#Less efficient

String Builder:

#StringBuilder are mutable class, which means when concatenate any text to the variable it allows us 

to modify the original value without creating a new object.

#Here Append method is used.

#Stringbuilder object is used.

#Insertion is done on the existing string

#StringBuilder is more efficient for large amounts of string manipulations


9.Constant vs readonly vs static?

Constant:

#Must be initialized at the time of its creation

#Value is evaluated at compile time.

Read only:

#Assigned in constructor and called at Runtime

#Value is evaluated at run time 

Static: 


10. Data set vs Data reader?

Dataset:

DataSet is a disconnected orient architecture that means there is no need of active connections during work with datasets and it is a collection of DataTables and relations between tables. It is used to hold multiple tables with data. You can select data form tables, create views based on table and ask child rows over relations. Also DataSet provides you with rich features like saving data as XML and loading XML data.

Data reader:

DataReader is used to read the data from database and it is a read and forward only connection oriented architecture during fetch the data from database. DataReader will fetch the data very fast when compared with dataset. Generally we will use ExecuteReader object to bind data to datareader.


11.Page life cycle?SILVER

(Start

Init

Load

Validation--viewstate

Events

Rendering)

All Life cycle Stages::

BeginRequest

AuthenticateRequest

AuthorizeRequest

ResolveRequestCache

AcquireRequestState

PreRequestHandlerExecute

ProcessRequest

Init

Load

Validate

Render

Unload

PostRequestHandlerExecute

ReleaserequestState

UpdateRequestCache

EndRequest


12.Reflections in Dotnet?

• It is a collection of classes which allow u to query assembly (class/object) metadata at runtime.

• Using reflection we can also create new types and their instances at runtime and invoke methods on these new instances.

• At runtime, the Reflection mechanism uses the PE file to read information about the assembly.

• We can dynamically invoke methods using System.Type.Invokemember

• We can dynamically create types at runtime using System.Reflection.Emit.TypeBuilder

• With reflection we can do the below

 we can dynamically create an instance of a type

 bind the type to an existing object

 get the type from an existing object

 invoke its methods or access its fields and properties


13.Authentication and Authorization?

Authentication: validating the user against his credentials

• Windows

• Form

• Passport

• None




• Password based authentication

• Device based authentication

• Biometric Authentication

• Retina Scanners

• Hand Scanners

Authorization: Allowing the specific resources according to his login

14.Http Get and Http Post?

• In HTTP GET method data passed through url QueryString using name value pair. It’s simpler and you can troubleshoot any problems simply by looking at the address bar in your browser because all values passed are displayed there.

• This is also the primary weakness of this method. The data being passed is visible and is limited in size to the maximum length of a request string


• In HTTP POST request data are embedded in a HTTP HEADER. So data are NOT visible to end user while you can see the data passed in HTTP GET method. 

• If you want to pass sensitive information/data, you should have to use HTTP POST request. Another advantage is that you can send larger amounts of information compare to HTTP GET method.

15.Array vs Array list?

Array:

Array is in the System namespace.

The capacity of an Array is fixed.

An Array is a collection of similar items.

An Array can have multiple dimensions

Array list:

ArrayList is in the System.Collections namespace.

ArrayList can increase and decrease size dynamically.

ArrayList can hold item of different types.

ArrayList always has exactly one dimension


16.Collections vs Generics?

Collections:

Collection we can keep adding elements to it..

collections can hold any objects..

Accessing the element is very simple and very fast in collections.

Removing the element in Collection is very simple

Generics:

Using generic collection classes provides increased type-safety and in some cases can provide better performance, especially when storing value types


17.Delegates?Multicast delegate?

• Delegate in C# is similar to a function pointer in C or C++.

• Delegate is type which holds the method(s) reference in an object. It is also referred as a type safe function pointers.

• Delegate allows the programmer to encapsulate a reference to a method inside a delegate object.

• The delegate object can then be passed to code which can call the referenced method, without having to know at compile time which method will be invoked.

• An interesting and useful property of a delegate is that it does not know or care about the class of the object that it references.

Multicast delegate:

• Delegate wraps a method. Calling delegate results in calling the method. It is possible to wrap more than one method in a delegate. This is known as a multicast delegate.

• If you make a call to a multicast delegate it will call all the functions it wraps in the order specified. Please note that functions in this case should not return any values.

18.Dictionary vs Hash Table?

Hash Table:

• Stored in two dimensional array and have a link format of Key and Value.

• The Hashtable object contains items in key/value pairs. The keys are used as indexes.

• The data type of Hashtable is object and the default size of a Hashtable is 16.

• The keys are used as indexes. We can search value by using their corresponding key.

• Items are added to the Hashtable with the Add() method.

• A close friend of Hashtable is Array (came from C/C++), it is an instance of System.Array class.


19.Assembly(Types), Metadata, Namespace?


20.Session types?

Session mode="inproc"...means the session will be stored on the webserver within your application

session mode="outproc"....means session will be stored on the server outside your application

session mode="stateserver"...means session will be stored in a temporary memory in the database

session mode="sqlserver"...means session will be stored in the database permanently.

Advantages:

It helps maintain user state and data all over the application.

It is easy to implement and we can store any kind of object.

Stores client data separately.

Session is secure and transparent from the user.

Disadvantages:

Performance overhead in case of large volumes of data/user, because session data is stored in server memory.

Overhead involved in serializing and de-serializing session data, because in the case of StateServer and SQLServer session modes, we need to serialize the objects before storing them.


21.Cookie?if disabled?

• Since they are stored on the client side in plain text, they are not secure.

• Number of cookies that can be stored and their size is limited.

• They don't work if security level is set too high in browser.

• Some people might just disable cookies on their browsers.

22.Connection Pooling and worker Process?

Application Pool 

This is one of the most important things you should create for your applications in a production environment. 

Application pools are used to separate sets of IIS worker processes that share the same configuration. 

Application pools enable us to isolate our web application for better security, reliability, and availability.


Worker Process:

The worker process serves as the process boundary that separates each application pool so that when 

one worker process or application has an issue or is recycled, other applications or worker processes are not affected.

Web Garden:

An application pool with multiple worker processes is called a Web Garden

Adv:

The worker processes in a Web Garden share the requests that arrive for that particular application pool. 

If a worker process fails, another worker process can continue processing the requests.


23.Webservice? where you used?

Web Service is an application that is designed to interact directly with other applications over the internet.

In simple sense, Web Services are means for interacting with objects over the Internet. 

The Web serivce consumers are able to invoke method calls on remote objects by using SOAP and HTTP over the Web. 

WebService is language independent and Web Services communicate by using standard web protocols and data formats, 

such as HTTP, XML and SOAP.

24.Webservice vs WCF service?

ASMX is:
  • easy and simple to write and configure
  • only available in IIS
  • only callable from HTTP
WCF can be:
  • hosted in IIS, a Windows Service, a Winforms application, a console app - you have total freedom
  • used with HTTP (REST and SOAP), TCP/IP, MSMQ and many more protocols
Web services can only be invoked by HTTP (traditional webservice with .asmx). While WCF Service or a WCF component can be invoked by any protocol (like http, tcp etc.) and any transport type. 

Second web services are not flexible. However, WCF Services are flexible. If you make a new version of the service then you need to just expose a new end. Therefore, services are agile and which is a very practical approach looking at the current business trends. 

We develop WCF as contracts, interface, operations, and data contracts. As the developer we are more focused on the business logic services and need not worry about channel stack. WCF is a unified programming API for any kind of services so we create the service and use configuration information to set up the communication mechanism like HTTP/TCP/MSMQ etc 


25.Access specifiers?

• Public - Access to same assembly or another assembly that references it.

• Private - Access to same class or struct.

• Protected - Access to same class or struct, or in a class that is derived.

• Internal - Access to any code in the same assembly, but not from another assembly.

• Protected Internal - Access to any code in the assembly in which it is declared, or from within a derived class in another assembly.




26.Ajax Controls names?Validation control names?

Ajax Controls:

calendar extender,

Modal Popup,

Filtered Text Box ,

WaterMark, 

Auto Complete ,

Rating


Validation control:

The RequiredField Validator control

The RangeValidator control

The RegularExpressionValidator control

The CompareValidator control

The customValidator control

The Validationsummary control

27.Can we create an instance for Abstract class?and interface?

No. Using inheritance we can implement.

28.Master page-- Page_pre init event?

To call a master page dynamically 

29.Dispose vs finalize?

• Finalize() is called by the runtime

• Is a C# equivalent of destructor, called by Garbage Collector when the object goes out of scope.

• Implement it when you have unmanaged resources in your code, and want to make sure that these resources are freed when the Garbage collection happens.

• Finalize() can NOT be overridden or called in C#.

• Since, Finalize() is called by the Garbage Collector, it is non-deterministic.




• Dispose() is called by the user

• Same purpose as finalize, to free unmanaged resources. However, implement this when you are writing a custom class, that will be used by other users.

• Overriding Dispose() provides a way for user code to free the unmanaged objects in your custom class.

• Dispose() has to be implemented in classes implementing IDispose interface.

• Dispose() method is called explicitly in the code itself.


30.Default Access specifier..?

The Default access specifier for the class in C# is Internal


31.Partial page rendering?

Partial-page rendering removes the need for the whole page to be refreshed

 as the result of a postback. Instead, only individual regions of the page that

 have changed are updated. As a result, users do not see the whole page
 
reload with every postback, which makes user interaction with the Web page 

more seamless. Microsoft ASP.NET AJAX enables you to add partial-page 

rendering to new or existing ASP.NET Web pages without writing client script.

32.Responce.Redirect vs server.transfer?

Responce.Redirect:

There is a Round trip

Previous page values are not accessible

Less performance

A state can be maintained in Response redirect but has a lot of draw backs

server.transfer

There is no Round trip

Previous page values are accessible

Performance wise its better

Information can be preserved in Server transfer through aparameter called preserveForm


33.Web.config vs App.config vs. Machine.config?

Web.config( App.config)

Machine level configuration

Can have more than one Web.config

Web.config overrides the machine.config file

Automatically installed when installing Visual Studio.


Machine.config

Application/folder level configuration

Only one Machine.config

Web.config overrides the machine.config file

Created when creating an ASP.Net web application


34. Global Events(global.asax)?

Application_Init

Application_Start

Session_Start

Application_BeginRequest

Application_EndRequest

Application_AuthenticateRequest

Application_Error

Session_End

Application_End


35.Constructor and its types?

• Constructor is used to initialize an object (instance) of a class.

• Constructor is a like a method without any return type.

• Constructor has same name as class name.

• Constructor follows the access scope (Can be private, protected, public, Internal and external).

• Constructor can be overloaded, means we can have constructors with different set of parameters.

• We can always make the call to one constructor from within the other constructor. 

• Only this and base keywords allowed in initializing constructors, other method calls will raise error.

types:

• Static Constructor

• Default Constructor

• Private Constructor

• Copy Constructor 

• Parameterized Constructor


36. Event bubbling?

Server Controls like DataGrid, DataGridView, DataList etc have other controls inside them. 

A control can participate in event bubbling through two methods that it inherits from the base class System.Web.UI.Control. These methods are OnBubbleEvent and RaiseBubbleEvent. 

Example an DataGridView can have an Textbox or an button inside it. These Child Controls cannot raise events by themselves, but they pass the event to the parent control (DataGridView), which is passed to the page as “ItemCommand” event. This process is known as Event Bubbling.










Sql-->

1.Function vs Stored procedure?

2.Truncate vs delete?

3. Perfomance tuning?

4.Top 2 salary?

5.Group by, order by.

6.Joins? types? Examples?(Cross vs inner)

7.Union vs Union All?

8.using 'case' how to update a table?

9.Transaction--Commit, roll Back?

10.Index? Types? 

11. In and Out parameters?

12. Why Stored procedure?

13. Sub Query ? # temp tables?

14.Types of Stored procedures?

15. char,varchar,nvarchar?

16.DML,DDL commands? 

17.Normalization?

• In relational database design, the process of organizing data to minimize redundancy is called normalization.

• It usually involves dividing a database into 2 or more tables and defining relationships between tables.

• Objective is to isolate data so that additions, deletions, and modifications can be made in just one table.

types:

• 1NF: Eliminate Repeating Groups

• 2NF: Eliminate Redundant Data

• 3NF: Eliminate Columns Not Dependent On Key

• 4NF: Isolate Independent Multiple Relationships

• 5NF: Isolate Semantically Related Multiple Relationships






No comments:

Post a Comment