Tuesday, 28 February 2017

C# basic interview questions Part-5

1. Ques : What are the advantages of generics?
Answer:
Generics has following advantages
  • It allows creating class, methods which are type-safe
  • It is faster. Because it reduce boxing/un-boxing
  • It increase the code performance
  • It helps to maximize code reuse, and type safety

2. Ques : What is extension methods and where can we use it?
Answer:
Extension methods provide a feature to add new capabilities to an existing type. You don’t need to make any modifications to the existing type, just bring the extension method into scope and you can call it like a regular instance method.
Extension methods need to be declared in a non generic, non-nested, static class.


3. Ques : What is difference between the “throw” and “throw ex” in .NET?
Answer:
  • throw : It throws the original exception and preserves its original stack trace.
  • throw ex: It throws the original exception but resets the stack trace, destroying all stack trace information until your catch block.

4. Ques : Can you serialize hashtable ?
Answer
No, You can’t Serialize Hash table.Because, In the C# serialization of any object not possible  that implements the IDictionary interface.


5. Ques : What is the difference between Debug.Write and Trace.Write in C#?
Answer
Debug.Write
  • It uses the Debug class.
  • It uses the time of application development.
  • It works only in debug mode.
  • It is used while debugging a project.
  • It runs in the same thread as main program executes.
  • It is used to find errors in the program.
  • If 'DEBUG' is defined during the compilation, Debug.Write will be emitted.
Trace.Write
  • It uses the Trace class.
  • It uses the time of application deployment.
  • It works in both case debug and release mode.
  • It is used in releasing version of applications.
  • It runs in different thread form main program execute thread.
  • It is used for testing and optimization even after an application is compiled and released.
  • If 'TRACE' is defined during the compilation, Trace.Write will be emitted.

6. Ques: What is the difference between an EXE and a DLL?
Answer:
EXE:
  •  Executable file can run independently.
  •  It runs in a separate process.
  •  It can’t be reused in application.
  •  it has a main function.
  • Can be started as stand alone.
DLL:
  • Dynamic link library is used as part of EXE or other DLL’s
  • It runs in application process memory.
  • It can be reused in application.
  • It does not have a main function.
  • Cannot be started as stand alone.

7. Ques:  What is strong name in .net ?
Answer:
A strong name consists of the assembly's identity  its simple text name, version number, and culture information,  a public key and a digital signature.


8. Ques: What is delay signing Dot Net ?
Answer:
Delay signing allows you to place a shared assembly in the GAC by signing the assembly with just the public key.This allows the assembly to be signed with the private key at a later stage, when the development process is complete and the component or assembly is ready to be deployed. This process enables developers to work with shared assemblies as if they were strongly named, and it secures the private key of the signature from being accessed at different stages of development.


9 Ques: What is side by side execution in .net ?
Answer:
Side-by-side execution is the ability to run multiple versions of an application or component on the same computer. You can have multiple versions of the common language runtime, and multiple versions of applications and components that use a version of the runtime, on the same computer at the same time.


10 Ques: Can we have different access modifiers on get/set methods of a property ?
Answer:
No we can not have different modifiers same property. The access modifier on a property applies to both its get and set accessors.

Sunday, 26 February 2017

WPF interview question Part 2

1. Ques: What are the common assemblies used in WPF?
Answer:
 WPF has three common assemblies. These are as below,
  • WindowsBase.dll:- This assembly defines the core types that constitute the infrastructure WPF API.
  • PresentationCore.dll:- As the name specifies this assembly specifies different types for WPF GUI layer.
  • PresentationFoundation.dll:- It defines the WPF control types, animation, multimedia and data binding support. It also specifies some other functionality. 

2. Ques: What are Freezable objects in WPF ?
Answer:
.NET 3.5 introduces a new type of objects called freezable objects. An object, which has its state locked down, so that it becomes unchangeable, is known as a freezable object. These objects are usually related to graphics sub-system. A freezable object has two states – frozen and unfrozen. When an object is frozen, it cannot be modified and it cannot even fires events but the unfrozen state, it works same as a normal object. Such objects perform better. It is also safer if they are required to be shared between threads.
Some freezable objects are – Brush, Pen, Geometry, Transform, and AnimationTimeline.


3. Ques: What are important Namespace in WPF ?
Answer:
The major subsystems are:
  • System.Windows:- It is the core namespace of WPF. You will find all the base classes such as, Application, DependencyObject , DependencyProperty and FrameworkElement here.
  • System.Threading.DispatcherObject: Most of the WPF classes derive from the DispatcherObject object to provides the Thread-Safe environment.
  • Windows.FrameworkElement: It is a base class that is inherited by all of the layout controls and other WPF Controls. FrameworkElement provides functionality related to the logical tree, styling, data binding and lifetime events.
  • System.Windows.Controls:- This namespaces contains all the controls of WPF. You will also find classes to work with complex controls such as PopUp, ScrollBar, StatusBar, TabPanel, etc. as well as all the basic controls.
  • System.Windows.Data:- This namespace is used by WPF for Data Binding. 
  • System.Windows.Input:- This namespace provides several classes for command handling, keyboard input, etc.
  • System.Windows.Markup:- This namespace helper classes for XAML markup code.
  • System.Windows.Media:- This namespace is responsible to work with images, audio, and multimedia.
  • System.Windows.Shapes:- This namespace provides core classes for UI such as Line, Rectangle, Ellipse, etc. 
  • System.Windows.Threading:- This namespace provides classes to work with multiple threads. 
  • System.Windows.Navigation:- This namespace provides classes for navigation between WPF pages particularly when working with Web Applications.
  • System.Windows.UIElements:- UIElement is a base class for most of the objects that have visual appearance and can process basic input.

4. Ques: What are Attached Properties in WPF ?
Answer:
Attached properties are a special kind of DependencyProperties. They allow you to attach a value to an object that does not know anything about this value.
For example, if the button element is located inside a Canvas element. the button has Top and Left properties that are prefixed with the parent element's name. Such a property is known as attached property.

5. Ques: What is ObservableCollection?  What are the uses of ObservableCollection.
Answer:
An ObservableCollection is a dynamic collection of objects of a given type. Objects can be added, removed or be updated with an automatic notification of actions. When an object is added to or removed from an observable collection, the UI is automatically updated. This happens because, when binding to an observable collection, WPF automatically adds a CollectionChanged event handler to the ObservableCollecion's events.

The ObservableCollection class exists in the System.Collections.ObjectModel namespace.

One of the biggest uses is that you can bind UI components to one, and they'll respond appropriately if the collection's contents change. For example, if you bind a ListView's ItemsSource to one, the ListView's contents will automatically update if you modify the collection.

6. Ques: How many types of Documents are supported by WPF ?     
Answer:   
WPF supports two types of documents
Fixed format Document -It is just like PDF Format. they display content regardless of screen size and resolution.
Flow format Document. -It adjust depending on screen size and resolution.


7. Ques: What are the types of windows in WPF?
Answer:   
WPF has three types of windows:
  • Normal Window
  • Page Window
  • Navigate Window

8. Ques: What are the advantage of using XAML?
Answer:   
The advantage of using XAML are given bellow
  • XAML code is clear to read, and they are short
  • Separation of designer code and logic
  • Tools like expression blend used for graphical design require XAML as source
  • It clearly separates the roles of designer and developer

9. Ques : What are the different types of brushes that WPF offers?
Answer:   
There are six different types of brushes

  • SolidColorBrush
  • LinearGradientBrush
  • RadialGradientBrush
  • DrawingBrush
  • VisualBrush
  • ImageBrush

10. Ques : Question:What are Templates and its type in WPF?
Answer:   
A Template is used to change how a control looks.
Types of templates:
Control template: How a control is rendered and behaves by specifying the visual structure and behavioral aspects.
Data template: To specify the visualization of data objects.
Hierarchical data template: Used over hierarchical structure like Tree View and Menu.

JQuery interview questions Part 3

1. Ques: What is JQuery.noConflict?
Answer:
jQuery no-conflict just overcome the conflicts between the different js frameworks or libraries.
When we use jQuery no-conflict mode, we are replacing the $ to a new variable and assigning to jQuery some other JavaScript libraries.Use the noConflict() method to specify a new name for the jQuery variable.

2. Ques: What is $(document).ready() function ?
Answer:
The ready event occurs when the DOM (document object model) has been loaded.Because this event occurs after the document is ready, it is a good place to have all other jQuery events and functions. The ready() method specifies what happens when a ready event occurs.


3. Ques: What is difference between prop() and attr() in Jquery ?
attr()
  • Get the value of an attribute for the first element in the set of matched elements.
  • gives you the value of element as it was defines in the html on page load
prop()
  • Get the value of a property for the first element in the set of matched elements.
  • It gives the updated values of elements which is modified via javascript/jquery
4. Ques: What is each() function in jQuery ?
Answer:
jQuery.each()is funtion which loop through a collection (object type or array type).it iterated by their index position and value in Array-like objects.


5. Ques: What is Dojo?
Answer:
Dojo is a third-party javascript toolkit for creating rich featured applications. Dojo is an Open Source DHTML toolkit written in JavaScript. It builds on several contributed code bases (nWidgets, Burstlib, f(m)), which is why we refer to it sometimes as a “unified” toolkit. Dojo aims to solve some long-standing historical problems with DHTML which prevented mass adoption of dynamic web application development.


6. Ques: Can we set session variables from JavaScript ?
Answer:
It's not possible to set any session variables directly from javascript as it is purely a client side technology.


7. Ques: Explain the each() function ?
Answer:
each() is the jquery function and it is used to iterate over jquery matched object list.
each() is a traversing method which works only jquery objects.
syntax :
$(selector).each(function(index,element))
  •  “index” is the index position of the selector.
  •  “selector” specifies the current selector where we can use “this” selector also.
  •   In the case when we need to stop the each loop early then we can use “return false;”
Example:
<script>
  $(document).ready(function(){
      $("button").click(function(){
          $("li").each(function(){
              alert($(this).text())
        });
    });
});
</script>


8. Ques: What is the use of param() method ?
Answer:
The param() method is used to represent an array or an object in serialize manner.While making an ajax request we can use these serialize values in the query strings of URL.
Syntax: $.param(object | array, boolValue)
“object | array” specifies an array or an object to be serialized.
“boolValue” specifies whether to use the traditional style of param serialization or not.

For example:
personObj=new Object();
empObject.name="Vijay";
empObject.age="29";
empObject.dept=”Marketing”;
$("#clickme").click(function()
{
     $("span").text($.param(empObject));
});


9. Ques: What is difference between id selector and class selector in jquery ?
Answer:

  • Id are unique in html page
  • Each element can have only one id
  • Each page can have only one element with that id
  • Classes are not unique in html page 
  • You can use the same class on multiple elements.
  • You can use multiple classes on the same element.

ex:
<div id="Body">
<h1>Tile of pages</h1>
<p class="para">here i am showing my blog</p>
<p class="para">css class applied here</p>
</div>

Saturday, 25 February 2017

MVC interview questions Part 4

1. Ques: What is Caching ?  What are the advantages of Caching in MVC application and  How implement caching in MVC application ?
Answer:
Caching provides frequently accessed data from memory. It is technique to  improving web application’s performance.
Advantages of Caching 
  • Reduce hosting server round-trips:When content is cached at the client, it can eliminate request to server.
  • Reduce database server round-trips: When content is cached at the web server, it can eliminate the database request.
  • Reduce network traffic: When content is cached at the client side, it it also reduce the network traffic.
  • Avoid time-consumption for reusable content: When reusable content is cached, it avoid the time consumption for reusable content.
  • Improve performance :Since cached content reduce round-trips, network traffic and avoid time consumption for reusable content which cause a improved in the performance.
By using Output Cache Filter we can implement cache  technique in mvc application

OutputCache filter: The OutputCache filter allow you to cache the data that is output of an action method.
By default, this attribute filter cache the data till 60 seconds. After 60 sec, if a call was made to this action then ASP.NET MVC will cache the output again.

You can enable the output caching for an action method or controller by adding an [OutputCache] attribute as shown below:

[OutputCache(Duration=30, VaryByParam="none")]
public ActionResult Index()
{
 ViewBag.Message = DateTime.Now.ToString();
 return View();
}

The output of the Index() action method will be cached for 30 seconds. If you will not defined the duration, it will cached it for by default cache duration 60 sec.


2. Ques: What is Razor View Engine in MVC?
Answer:
  • The Razor View Engine is an advanced view engine, available with MVC 3.0 and later versions.
  • Namespace for ASPX view Engine is Web.Razor.
  • File Extension for this View Engine is .cshtml (Razor C#), for Views, Partial Views, Editor Template and Layout Pages. .vbhtml (Razor VB.NET), for Views, Partial Views, Editor Template and Layout Pages.
  • Supports TDD (Test Driven Development).
  • Razor Engine is little bit slow as compared to Web form Engine.
  • Razor Engine prevents XSS attacks(Cross-Site Scripting Attacks) means it encodes the script or html tags like <,> before rendering to view.
  • Razor syntax is easy to understand and much clean than Web Form syntax. Razor uses @ symbol to make the code.

3. Ques: Explain attribute based routing in MVC?
Answer:
  • Attribute based routing provides more control over the URIs by defining routes directly on actions and controllers in your ASP.NET MVC application and WEB API. 
  • It is new type of routing introduce in ASP.NET MVC5
attribute based routing Implement in two way one Controller level and another action level

Controller level attribute routing

[RoutePrefix("EmployeeHome")]
[Route("{action=index}")] //default action

public class EmployeeController : Controller
{
 //new route: /EmployeeHome/Index
 public ActionResult Index()
 {
 return View();
 }

 //new route: /EmployeeHome/About
 public ActionResult About()
 {
 ViewBag.Message = "Your application description page.";
 return View();
 }

 //new route: /EmployeeHome/Contact
 public ActionResult Contact()
 {
 ViewBag.Message = "Your contact page."; return View();
 }

}

Action level attribute routing

public class EmployeeController : Controller
{
 [Route("Employee/{id:int:min(100)}")] //route: /Employee/100
 public ActionResult Index(int id)
 {
 return View();
 }

 [Route("Employee/about")] //route" /Employee/about
 public ActionResult About()
 {
 ViewBag.Message = "Employee about page.";
 return View();
 }

 //route: /Home/Contact
 public ActionResult Contact()
 {
 ViewBag.Message = "Employee contact page.";
 return View();
 }
}


4. Ques:  What are Display Modes in MVC4 ?
Answer:
Display modes use a convention-based approach to allow selecting different views based on the browser making the request. The default view engine fi rst looks for views with names ending with .Mobile.cshtml when the browser’s user agent indicates a known mobile device. For example, if we have a generic view titled Index.cshtml and a mobile view titled Index.Mobile.cshtml, MVC 4 will automatically use the mobile view when viewed in a mobile browser.
Additionally, we can register your own custom device modes that will be based on your own custom criteria — all in just one code statement. For example, to register a WinPhone device mode that would serve views ending with .WinPhone.cshtml to Windows Phone devices, you’d use the following code in the Application_Start method of your Global.asax:

Thursday, 23 February 2017

WCF interview question Part 1

1. Ques: What is WCF ? What are the advantages of WCF ?
Answer:
  • WCF stands for Windows Communication Foundation introduce by Microsoft in .NET Framework 3.5 in Visual Studio .NET 2008.
  • WCF is Microsoft's unified programming model for building service-oriented application.
  • It is a framework for building service-oriented applications.
  • Using WCF we can send data as asynchronous messages from one service endpoint to another. 
  • It is a combination of multiple existing .NET Technologies like asmx, .NET Remoting, Enterprise Services, WSE and MSMQ.
Advantages of WCF
  • Interoperability: A single platform used to exchange information.
  • Security and Reliability: Security in the form of auditing, authentication, authorization, confidentiality and integrity of messages.
  • Speed:Its faster than Web services

2. Ques: What are the main components of WCF Service?
Answer:
Three main component in wcf services
Service class : A wcf Service class implements some service as a set of methods.
Hosting enviroment:  wcf supports four types of hosting, IIS, Windows Process Activation Services (WAS), self-hosting and Windows Services.
End Point : Endpoints provide clients access to the functionality offered by a WCF service.
Each endpoint consists of four properties:
  • Address: An address that indicates where the endpoint can be found. 
  • binding: A binding that specifies how a client can communicate with the endpoint. 
  • contract: A contract that identifies the operations available.
3. Ques:  How many way we can host a WCF service?
Answer:
we can hosting a WCF Service in four way:
  • Self-Hosting
  • Windows Service
  • Internet Information Services (IIS)
  • Windows Activation Services (WAS)
Self-Hosting:-
In self hosting the WCF service hosted within the project solution (Windows application or web application ).
To implement self-hosting we have to include System.Service.Model.ServiceHost namespace.
advantages of self-hosting:
  • Is easy to use: With only a few lines of code you have your service running.
  • Is flexible: You can easily control the lifetime of your services through the Open() and Close() methods of ServiceHost<T>.
  • Is easy to debug: Debugging WCF services that are hosted in a self-hosted environment provides a familiar way of debugging, 
  • Is easy to deploy: 
  • Supports all bindings and transports: 

4. Ques: What is Address, Binding And Contract in wcf ?
Answer:-
Address: The address uniquely identifies the endpoint and tells potential consumers of the service where it is located.
  • A Uri property, which represents the address of the service.
Binding: The binding specifies how to communicate with the endpoint. This includes:
  • The transport protocol to use (for example, TCP or HTTP).
  • The encoding to use for the messages (for example, text or binary).
  • The necessary security requirements (for example, SSL or SOAP message security).
Contracts: The contract outlines what functionality the endpoint exposes to the client. A contract specifies:
  • What operations can be called by a client.
  • The form of the message.
  • The type of input parameters or data required to call the operation.
  • What type of processing or response message the client can expect.

5. Ques: What is Binding in WCF ? What are the types of binding?
Answer:-
Binding describes how a client is going to communicate to WCF service. Binding is used as per client need. It supports different types of protocol to communicate with client and different types of encoding to transfer the data over the internet. So, basically binding is nothing but it is a way of communication between client and service as per client need.

Different type of binding supported by wcf:-
  • BasicHttpBinding: Basic Web service communication. No security by default.
  • WSHttpBinding: Web services with WS-* support. Supports transactions.
  • WSDualHttpBinding: Web services with duplex contract and transaction support.
  • WSFederationHttpBinding: Web services with federated security. Supports transactions.
  • MsmqIntegrationBinding: Communication directly with MSMQ applications. Supports transactions.
  • NetMsmqBinding: Communication between WCF applications by using queuing. Supports transactions.
  • NetNamedPipeBinding: Communication between WCF applications on same computer. Supports duplex contracts and transactions
  • NetPeerTcpBinding: Communication between computers across peer-to-peer services. Supports duplex contracts
  • NetTcpBinding:Communication between WCF applications across computers. Supports duplex contracts and transactions

Wednesday, 22 February 2017

Oops concept questions Part-4

1. Ques: How many type of Access modifier in C# ?
Answer:-
Public modifier : Public member can be accessed by any other code in the same assembly or outside the assembly.

Private modifier : Private  can be accessed only by code in the same class or struct.

Protected modifier: Protected can be accessed only by code in the same class or struct, or in a class that is derived from that class.

Internal modifier: Internal member can be accessed by any code in the same assembly, but not from another assembly.

Protected internal modifier: The type or member can be accessed by any code in the assembly in which it is declared, or from within a derived class in another assembly.


2. Ques: What is difference between Abstract Class and an Interface ?
Answer:-
Abstract class:
  • We can not create an object (instance) of an abstract class.
  • An interface cannot implementation any code, It has only the signature.
  • We can not implement multiple inheritance in Abstract class.
  • Abstract class can have static methods, main method and constructor.
  • The abstract keyword is used to declare abstract class.
  • It is Collection of abstract method and Concrete method.
  • Abstract class can have constructor.
  • Abstract class is faster than interface.
Interface:
  • Interface has only the signatures of the methods,property not the implementation .
  • We can implement multiple inheritance in Interface.
  • We can not declare a member field in an Interface.
  • We can not use any access modifier in interface by default everything is public.
  • Interface class don't have static methods, main method and constructor.
  • The interface keyword is used to declare interface.
  • It is Collection of abstract method only.
  • Interface is slower as it takes some time to find implemented method in class.
  • Interface slower than Abstract class.

3. Ques: What is Destructor?
Answer:
A Destructor is automatically invoked when an object is finally destroyed. The name of the Destructor is same as class and prefixed with a tilde (~)

A Destructor is used to free the dynamic allocated memory and release the resources. You can Implement a custom method that allows to control object destruction by calling the destructor.
  • Destructors don not have any return type
  • Destructors are always public
  • Destructors can not be overloaded


4. Ques: What is the difference between Shadowing(Method hiding) and Overriding?
Answer:

Shadowing (Method hiding):
  • You can shadow a base class member in the derived class by using the keyword New.
  • The method signature, access level and return type of the shadowed member can be completely different than the base class member.
  • A method or function of the base class is available to the child (derived) class without the use of the “overriding” keyword.
  • The compiler hides the function or method of the base class. This concept is known as shadowing or method hiding.
  • In the shadowing or method hiding, the child (derived) class has its own function, the same function is also available in the base class.
  • Shadowing redefines an entire method or function.
  • We can change the access modifier.
Overriding:
  • Method overriding is an important feature of OOPS that allows us to re-write a base class function or method with a different definition.
  • Overriding is also known as “Dynamic Polymorphism” because overriding is resolved at runtime.
  • The method signature, access level and return type of the hidden member has to be same as the base class member
  • In other words both methods (base class method and derived class method) have the same name, same number and same type of parameter in the same order with the same return type.
  • The overridden base method must be virtual, abstract or override.
  • Overriding redefines only the implementation of a method or function.
  • We cannot change the access modifier. The access modifier must be the same as in the base class method or function.

Tuesday, 21 February 2017

C# basic interview questions Part-4

1. Ques: What is indexer ?
Answer:
Indexer Concept is object act as an array.When you define an indexer for a class, this class behaves similar to a virtual array. You can then access the instance of this class using the array.
  • An indexer is also similar to a property.
  • Indexer an object to be indexed in the same way as an array.
  • Indexer modifier can be private, public, protected or internal.
  • The return type can be any valid C# types.
  • Indexers in C# must have at least one parameter. Else the compiler will generate a compilation error.
public dataType this[int index]
{
    get
    {
         return aValue;
    }
    set
    {
    }
}

2. Ques: What is the difference between string and StringBuilder in c#?
Answer:
String:-
  • It’s an immutable. means once we create its object of string and if we modify it will create new instances.
  • Any action it will create new instance every time.
  • We don’t have any append keyword in string.
  • During string concatenation, additional memory will be allocated.
  • It is under System namespace.
  • Performance wise string is slow.
StringBuilder:-
  • StringBuilder is mutable.
  • StringBuilder will use same instance of object to perform any action
  • we can use append keyword along with StringBuilder.
  • During string concatenation, additional memory will be allocated if and only if the string buffer’s capacity is reached.
  • Stringbuilder belongs to System.Text namespace
  • StringBuilder gives better performance while performing repeated operation over a string. 

3. Ques: What are the differences between IEnumerable and IQueryable?
Answer:
IEnumerable:-
  • IEnumerable exists in the System.Collections namespace.
  • IEnumerable is suitable for querying data from in-memory collections like List, Array and so on.
  • IEnumerable doesn’t move between items, it is forward only collection.
IQueryable:-
  • IQueryable exists in the System.Linq Namespace.
  • IQueryable is suitable for querying data from out-memory (like remote database, service) collections.
  • If we need to do any manipulation with the collection like Dataset and other data sources, use IQueryable. 

4. Ques:  What is difference between is and as operator in C# ?
Answer:
"is" operator to check the object type. If the two objects are of the same type, it returns true and false if not.
"as" operator to check the object type. If the two objects are of the same type, it returns object else it returns null.


5. Ques: What is Automapper ?
Answer:
AutoMapper is an object-to-object mapper, which allows you to solve issues with mapping of the same properties in one object of one type to another object of another type.


6. Ques: How do install and uninstall assembly in GAC ?
Answer:
install- gacutil -i <assembly name>
uninstall-gacutil -u <assembly name>


7. Ques: What is Just In Time Compiler in dot net framework ?
Answer:
It is a compiler which converts MS IL (Microsoft Intermediate Language) code to Native Code (i.e. CPU-specific code that runs on the same computer architecture). Just-In-Time compiler- it converts the language that you write in .Net into machine language that a computer can understand.

There are 3 types of JITs
  • Pre-JIT compiler (Compiles entire code into native code completely in a single Operation)
  • Econo JIT compiler (Compiles only methods(Code) called at Runtime)
  • Normal JIT compiler (Compiles only that part of code called at Runtime and places in cache)

8. Ques: What are the advantages and disadvantages of get and set properties in C#?
Answer:
Advantages of properties (get/set):
  • Ability to add code later on without recompiling assemblies that reference this.
  • Ability to provide private/protected/internal set and public get (or any other combination).
  • Public fields are not CLS compliant.
Disadvantages of properties (get/set):
  • Slower to access (both read and write).
  • Can't pass as ref arguments to methods.

9. Ques: Do events have return type ?
Answer:
No, events do not have return type. 


10. Ques: Can event’s have access modifiers ?
Answer:
Event’s are always public as they are meant to serve every one registering to it. But you can access modifiers in events.You can have events with protected keyword which will be accessible only to inherited classes.You can have private events only for object in that class. 

Monday, 20 February 2017

ASP.NET interview questions Part-5

1. Ques: What are the new features in ASP.NET 4.5 ?
Answer:
Following are the new feature in asp.net 4.5
  • Bundling and Minification Feature
  • Strongly Typed Data Controls
  • Model Binding - Isolating the Web Form from the Model
  • Value Providers
  • Support for OpenID in OAuth Logins
  • Improved paging in ASP.NET 4.5 GridView control
  • Improved asynchronous programming.
  • Support for web sockets.
  • Support for HTML5 form types.
  • Page Inspector.
  • ASP.NET Web API
  • NET for Metro style Apps
  • Portable Class Libraries
  • Core New Features and Improvements
  • Parallel Computing.
  • Networking.
  • Support for Arrays Larger than 2 GB on 64-bit Platforms.
  • Enhanced Background Server Garbage Collection.
  • Support for Timeouts in Regular Expression Evaluations.
  • Support for Unicode 6.0.0 in Culture-Sensitive Sorting and Casing Rules on Windows 8.
  • Simple Default Culture Definition for an Application Domain.
  • Internationalized Domain Names in Windows 8 Apps.

2. Ques: What is the difference between user control and custom control?
Answer:
User Control:-

  • A tightly coupled control w.r.t code and UI
  • Derives from UserControl
  • Has static layout
  • It Can't be added to the toolbox.
  • Defines a set of controls.
  • Not very flexible like a Custom Control
  • It is useful static layout
  • Defines UI as normal XAML.
  • It can not compled into DLL.
  • Hard to Create.
  • A Seprate Copy of control required in each application.

Custom Control:-

  • A loosely coupled control w.r.t code and UI
  • Derives from Control
  • Has dynamic layout
  • It can be added in toolbox.
  • Defines a single control.
  • More flexible.
  • It is useful Dyanamic layout.
  • Defines UI in a ResourceDictionary.
  • It can compled into DLL.
  • Easy to Create.
  • A single Copy of control required in each application.


3. Ques: What is difference between server control and html control in asp.net ?
Answer: 
Server Controls:-
Server Controls are Server side controls and it executed on Server.
These controls Trigger Server side events.
Server Controls provides maintained State(view state) across requests.
It Provides set of properties that can be manipulated from server side code.
Server control inherits from System.Web.UI.

HTML Controls:
Html controls are client side controls and it executed on Browser.
These controls Trigger client side events.
HTML Controls can be maintained State using Page-level scripts.
It has the basic set of HTML attributes attached to each element.


4. Ques: What is Ispostback in asp.net and how to use it ?
Answer: 
IsPostBack is a property of the Asp.Net page that tells whether or not the page is on initial load.
using of the IsPostback Property we can check that page is Postback or not if page postback property is true then page is being post back if property is false then page is not postback.

Is Postback is normally used on page _load event to detect the Is page is getting loaded for the first time or not
protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        // generate form;
    }
    else
    {
        //process submitted data;
    }
}

5. Ques: What's the difference between eval() and bind() in asp.net
Answer:
eval()
  • eval() is one way binding.
  • If you bind a value using Eval, it is like a read only. You can only view the data.
bind()
  • Bind() is two way binding.
  • If you bind a value using Bind and if you do some change on the value it will reflect on the database also

6. Ques:  What is difference between View State and Session State ?
Answer:
View State
  • View State is maintained the state in page level only.
  • View State of one page is not visible in another page.
  • It store information on client side.
  • View State persist the value of page in the client side(browser) when post back operation done.
  • View State used to persist the page specific data on the client side.
Session state
  • Session state is maintained the state in Session level.
  • Session state value is available in all page within a user session.
  • Session state information stored in server.
  • Session state persist the data of particular user in the server.This data available till user close the browser or session time complete.
  • Session state used to persist the user specific data on the server side

7. Ques:  What is Cross Page Posting in ASP.Net?
Answer:
Cross page postback is the concept which is used to submit one page (Default.aspx) controls to another page (Default2.aspx) and access those page (Default.aspx) control values in another page

Cross page posting is a new feature introduced in ASP.NET 2.0, which eases the life of developers previously they have to use Server.Transfer which has its own advantages and disadvantages but now this is a part of ASP.NET which results flexibility and efficiency.


8. Ques: How ViewState affect performance? What is the ideal size of a ViewState ? How can you compress a viewstate?
Answer:
Viewstate stores the state of controls in HTML hidden fields. At times, this information can grow in size. This does affect the overall responsiveness of the page, thereby affecting performance. The ideal size of a viewstate should be not more than 25-30% of the page size.

Viewstate can be compressed to almost 50% of its size. .NET also provides the GZipStream orDeflateStream to compress viewstate.


9. Ques:  What is protected configuration in asp.net ?
Answer:
ASP.NET 2.0 includes a protected configuration system for encrypting and decrypting configuration information. This includes methods in the .NET Framework that can be used to programmatically encrypt or decrypt configuration information.
   The sensitive information is stored in an ASP.NET application is the Web.config file. To help secure information in configuration files, ASP.NET provides a feature called protected configuration, which enables you to encrypt sensitive information in a configuration file. A configuration file that encrypts the connection string values using protected configuration does not show the connection strings in clear text, but instead stores them in encrypted form.

ASP.NET interview questions Part-4

1. Ques: What is the difference between WCF  and web services? 
Answer:
Windows Communication Foundation : (WCF) is a framework for building service-oriented applications. Using WCF, you can send data as asynchronous messages from one service endpoint to another. It is framework to make inter-process communication easier like web services, Remoting, MS Message Queuing,
  • It can be hosted in many form like IIS, windows activation service, Self-hosting, Windows service 
  • One-Way, Request-Response, Duplex are different type of operations supported in WC.
  • System.Runtime.Serialization namespace is used for serialization.
  • Can be accessed through HTTP, TCP, Named pipes, MSMQ, Pear to pear .
  • Supports multi-threading by using ServiceBehaviour class.
  • Security, Reliable messaging, Transactions.
  • WCF are faster than Web Services.
  • Supports various protocols like HTTP, HTTPS, TCP, Named Pipes and MSMQ.
  • ServiceContract and OperationContract attributes are used for defining WCF service.

Web Services: A Web Service is programmable application logic accessible via standard web protocols. One of these web protocols is the Simple Object Access Protocol (SOAP).

  • It can be hosted in IIS Only.
  • One-way, Request- Response are the different operations supported in web service.
  • System.Xml.serialization name space is used for serialization.
  • Can be accessed through HTTP, TCP, Custom.
  • Support security but is less secure as compared to WCF.
  • Web Services are slower than WCF.
  • Doesn’t support multi-threading.
  • Supports only HTTP, HTTPS protocols.
  • WebService and WebMethod attributes are used for defining web service.

2. Ques: Difference between HttpGet and HttpPost requests?
Answer:
GET Request:-
Data is submitted as a part of url.
Data is visible to the user as it posts as query string.
It is not secure but fast and quick.
It can be cached.
GET requests remain in the browser history.
GET requests can be bookmarked.
GET requests should never be used when dealing with sensitive data.
GET requests have length restrictions.
GET requests should be used only to retrieve data.

POST Request:-
Data is submitted in http request body.
Data is not visible in the url.
It is more secured but slower as compared to GET.
It can not be cached.
POST requests do not remain in the browser history.
POST requests cannot be bookmarked.
In this no restrictions on data length.


3. Ques: What is difference between file-based dependency and key-based dependency ?
Answer:
file-based dependency:-  file-based dependency, the dependency is on a file saved in a disk.
key-based dependency:- In key-based dependency, It depend on another cached item.


4. Ques: What are the various types of validation controls provided by ASP.NET?
Answer:
ASP.NET provides 6 types of validation controls

1. RequiredFieldValidator - It is used when Use does not want the filed to be empty. It checks if the control has any value or not.
2. RangeValidator - It checks if the value in validated control is within the specified range or not.
3. CompareValidator -It checks if the value in controls matches  specific values or not.
4. RegularExpressionValidator -It checks if the value matches a specific regular expression or not.
5. CustomValidator -It Used to define User Defined validation.
6. Validation Summary - Displays summary of all current validation errors on an ASP.NET page.


5. Ques: What is the Global.asax.cs used for?
Answer:
The Global.asax.cs is used to implement application and session level events in asp.net application.


6. Ques: What is the difference between server.transfer and response.redirect in asp.net ?
Answer:

Response.Redirect 
  • In this redirect the request to some plain HTML pages on our server or to some other web server
  • we don't care about causing additional roundtrips to the server on each request.
  • we do not need to preserve Query String and Form Variables from the original request.
  • we want our users to be able to see the new redirected URL where he is redirected in his browser (and be able to bookmark it if its necessary).
Server.Transfer
  • In this transfer current page request to another .aspx page on the same server.
  • we want to preserve server resources and avoid the unnecessary roundtrips to the server.
  • we want to preserve Query String and Form Variables (optionally).
  • we don't need to show the real URL where we redirected the request in the users Web Browser.

7. Ques:  What is Scavenging?
Answer:
It is the process of deleting items from the cache when memory is scarce. Items are removed when they have not been accessed in some time or when items are marked as low priority when they are added to the cache. ASP.NET uses the CacheItemPriority object to determine which items to scavenge first. CacheItemPriority.High assigns a priority level to an item so that the item is least likely to be deleted from the cache.


8. Ques:  What is Cross Page Posting? How is it done?
Answer:
Cross page postback is the concept which is used to submit one page (Default.aspx) controls to another page (Default2.aspx) and access those page (Default.aspx) control values in another page (Default2.aspx).
                By default, ASP.NET submits a form to the same page. In cross-page posting, the form is submitted to a different page. This is done by setting the ‘PostBackUrl’ property of the button(that causes postback) to the desired page. In the code-behind of the page to which the form has been posted, use the ‘FindControl’method of the ‘PreviousPage’ property to reference the data of the control in the first page.


9. Ques: What are Master Pages?
Answer:
ASP.NET master pages allow you to create a consistent layout for the pages in your application. A single master page defines the look and feel and standard behavior that you want for all of the pages (or a group of pages) in your application.

  • Master pages is a template that is used to create web pages with a consistent layout throughout your application.
  • Master Pages contains content placeholders to hold page specific content.
  • When a page is requested, the contents of a Master page are merged with the content page, thereby giving a consistent layout.

Saturday, 18 February 2017

WPF interview question Part 1

1. Ques: Explain the architecture of WPF ?
Answer:


WPF architecture 3 layered architecture which have Managed layered, Unmanaged layered, Core API layered 

Managed layered : This layer has tow part Presentation Framework and Presentation Core.
  • Presentation Framework: This section has features like application controls , layouts . Content etc which helps you to build up your application. PresentationFamework DLL is responsible for this layer. 
  • Presentation Core: This is a low level API exposed by WPF providing features for 2D , 3D , geometry etc.
Unmanaged layered: this layer also called as MiliCore API Layer. Mili stands for media integration library. This section is a unmanaged code because it acts like a bridge between WPF managed and DirectX / User32 unmanaged API.

Core API layered : This layer has OS core components like Kernel, User32, GDI, Device Drivers, Graphic cards etc. These components are used by the application to access low level APIs. User32 manages memory and process separation.


2. Ques:What is dependency property? What are the Advantages of a Dependency Property and why we use it?
Answer:
  • Dependency property is a specific type of property which extends the CLR property. 
  • It is a property whose value depends on the external sources, such as animation, data binding, styles, or visual tree inheritance.
  • Dependency property also has the builtin feature of providing notification when the property has changed, data binding and styling.
Advantages of a Dependency Property:-
  • Less memory Uses:The Dependency Property stores the property only when it is altered or modified. Hence a huge amount of memory for fields are free.
  • Property value inheritance:It means that if no value is set for the property then it will return to the inheritance tree up to where it gets the value.
  • Change notification and Data Bindings:Whenever a property changes its value it provides notification in the Dependency Property using INotifyPropertyChange and also helps in data binding.
  • Participation in animation, styles and templates:A Dependency Property can animate, set styles using style setters and even provide templates for the control.
  • CallBacks: Whenever a property is changed you can have a callback invoked.
  • Resources:You can define a Resource for the definition of a Dependency Property in XAML.
Dependency Property can used for -
  • If you want to set the style
  • If you want data binding
  • If you want to set with a resource (a static or a dynamic resource)
  • If you want to support animation

3. Ques: What is routed event ?
Answer:
A routed event is event that can invoke handlers on multiple listeners in an element tree rather than just the object that raised the event. RoutedEvents has three type
  • Direct Event
  • Bubbling Event
  • Tunnel Event
Direct event is similar to events in Windows forums which are raised by the element in which the event is originated.

Bubbling Event
A bubbling event begins with the element where the event is originated. Then it travels up the visual tree to the topmost element in the visual tree. So, in WPF, the topmost element is most likely a window.

Tunnel Event
Event handlers on the element tree root are invoked and then the event travels down the visual tree to all the children nodes until it reaches the element in which the event originated.


4. Ques: Explain the WPF object hierarchy?
Answer:-

Object
: - Object is the main class for all .Net classes and  it is the base class for all wpf classes.

Dispatcher: -It is the base class for any object which wants to accessed only by its own thread. It means the object that derives from DispatcherObject is going to be accessed by only its own thread and if any other thread tries to access that object gives error. In this way DispatcherObject object provides Thread-Safe environment. Most of the WPF classes derive from the DispatcherObject object to provides the Thread-Safe environment.

DependencyObject: If any object supports dependency properties in WPF means it derives from the base class DependencyObject. DependencyObject provides GetValue() & SetValue() methods that are central to dependency properties.

Visual: - Visual is the base class for all objects which has their own visual representation.

UI Element: - It is the base class for all Visual objects with supported events, command binding, layout, focus...etc.

Framework element: - This class supports for templating , styles , binding , resources and common mechanisms for Windows-based controls such as tooltips and context menus.

5. Ques: Explain the Framework element hierarchy?
Answer:-





























6. Ques: what is prism in WPF ?
Answer:
Prism is the Microsoft Patterns and Practices Team official guidance for building "composite applications" in WPF and Silverlight. Its intended to provide guidance on the best practices for building large scale applications which are flexible in terms of development and maintainability.


7. Ques: What is the Application Lifetime in WPF?
Answer:
 The main events fired from Application include:

Startup :
Application is starting up.

Exit :
Fired when an application is shutting down.

Activated :
Fired when an application gets focus, i.e. becomes the foreground application

Deactivated :
Fired when application loses focus, i.e. is no longer the foreground application

DispatcherUnhandledException :
Fired when an exception is thrown, but not yet handled. You canchoose to handle the exception or not

SessionEnding :
Fired when Windows is being shut down due to either logoff or Windows shutdown.You can cancel the shutdown sequence.

You can add custom code for any of these events by just overriding the OnEventName method in yourApplication-derived class, e.g. OnStartup

Friday, 17 February 2017

SQL Server interview question Part 4

1. Ques: What is Index ? how many possible index combinations in table ?
Answer: 
Index help  to retrieve the data quicker in SQL server. An index can be created in a table to increase the performance of application and we can getting the data more quickly and efficiently. Effective indexes are one of the best ways to improve performance in a database application.indexes are one of the best ways to improve performance in a database application.

Syntax to Create Index :
CREATE INDEX INDEX_NAME ON TableName (COLUMN_NAME)

There are two types of Indexes in SQL server .
  • Clustered indexes
  • non-clustered indexes.
A table can have one of the below indexes combinations
  • No Indexes
  • A clustered index
  • A clustered index and many non-clustered indexes
  • A non-clustered index
  • Many non-clustered indexes


2. Ques: What is difference between Clustered Index and Non-Clustered Index ?
Answer: 
Clustered Index
  • There is only one clustered index for a table.
  • It is made on the primary key.
  • The leaf nodes of a clustered index contain the data pages.
  • Sort the records and store them physically according to the order.
  • Do not need extra space to store logical structure.
  • It doesn’t allow null values
  • Assigned for primary key
  • Reading from a clustered index is much faster than Non-Clustered Index.
Non-Clustered Index
  • There can be only 249 non-clustered indexes for a table.
  • It is made on the any key.
  • The leaf node of a non clustered index does not consist of the data pages. Instead, the leaf nodes contain index rows.
  • Create a logical order for data rows and use pointers to physical data files.
  • Use extra space to store logical structure.
  • It allow one null values
  • Assigned for unique key
  • Reading from Non-Clustered Index is slower than Non-Clustered Index.

3. Ques: What is difference between Delete and Truncate command in SQL server ?
Answer:
Delete :

  • The DELETE command is used to remove rows from a table based on WHERE condition.
  • DELETE is a DML command.
  • DELETE retain the identity column.
  • DELETE can be rollback.
  • DELETE command can the fired Trigger.
  • DELETE is slower than TRUNCATE.
  • we can use conditions(WHERE clause) in DELETE.
  • Delete can be used with indexed views.
  • DELETE using a row lock, each row in the table is locked for deletion.


Truncate :

  • TRUNCATE removes all rows from a table.
  • TRUNCATE is a DDL command.
  • Identify column is reset to its seed value.
  • TRUNCATE can't be rollback.
  • TRUNCATE command doesn't get fired Trigger.
  • TRUNCATE is much faster than DELETE.
  • we can't use conditions(WHERE clause) in TRUNCATE.
  • Truncate cannot be used with indexed views.
  • TRUNCATE using a table lock and whole table is locked for remove all records.



4. Ques: What are the difference between Row_Number(), Rank() And Dense_Rank() functions in SQL Server ?
Answer:
Row_Number(): It give unique numbers to each row within the PARTITION given the ORDER BY clause.
ex:  Select Column1 , ROW_NUMBER(Column2) OVER() FROM tableName

RANK(): It give unique value to each distinct Row, but it leaves a gaps between the groups.
ex: Select EmployeeName, EmpSalary ,rank() over(order by EmpName) as rankID from tblemployee

Dense_Rank(): It give unique value to each distinct Row, but it will not leave gaps between groups.
ex: Select EmployeeName, EmpSalary , DENSE_RANK() over(order by EmpName) as DrankID from tblemployee


5. Ques: Explain the different types of isolation levels in SQL Server.
Answer:
SQL Server supports these transaction isolation levels (from lower level to higher level)
  • Read Uncommitted
  • Read Committed
  • Repeatable Read 
  • Serializable
  • Snapshot
Read Uncommitted:
  • In this level, One transaction can read the data which is modified by some other transactions but still not committed.
  • It is lowest level and DIRTY READS got here.
Read Committed:
  • In this level,One transaction prevents the reading data which are modified by some other transactions but still are not committed yet.
  • It eliminates the problem of Dirty read.
  • It is the default Isolation set by the SQL Server for any Database.
Repeatable Read:
  • It does not allows any transaction to read a data that is being modified by some other transaction but not committed yet. 
  • In Repeatable Read isolation levels Shared locks are acquired. 
Serializable:
  • In this level,it  do not allow any transaction to read the data unless the other transactions completed their data modification operation. 
  • Serializable isolation level use to prevented  PHANTOM reads.
Snapshot :
  • In this level,transaction recognize only data which is committed before the start of the transaction. 
Isolation Level
Dirty Read
Lost Update
Unrepeatable
Read 
   Phantom       Records
     Read uncommitted
yes
yes
yes
yes
     Read committed
No
yes
yes
yes
     Repeatable read
No
no
no
yes
     Serializable
No
no
no
no






6. Ques: What is dirty read ?

Answer:
A dirty read happen when a transaction is allowed to read data from a row that has been modified by another transaction and not yet committed.

7. Ques: What is Phantom Read ?
Answer:
Phantom read occurs where in a transaction execute same query more than once, and the second transaction result set includes rows that were not visible in the first result set.

8. Ques: What are the several concurrency issues  in SQL Server ?
Answer:
Lost Update
Dirty Read
Non-Repeatable Read
Phantom Reads

9. Ques: What is lock in SQL server ? How many types of lock SQL server.
Answer:
Locking is preventing to acquire one transaction if other transaction already in use.
it main use for proper data modification by preventing other transactions to acquire a lock on the object higher in lock hierarchy.
What is lock in Sql server. how many types of lock.

Types of locks;
Shared (S) –It is use for Used for select operations.
            It is read-only operations.
            It Enable other sessions to perform select operations but prevent updates.
            SELECT statement Generally use in Shared mode.

Exclusive lock (X) :Only one Query can access the object.
                    It is Used for DML operations.
                    updates cannot be made to the same resource at the same time.

Update lock (U):It Prevents other update locks at row level.
               : It slove the problem of deadlock Cycle.

Intent shared (IS): Intent Locks are used for establish a lock Hierarchy.
                    It is three type,
                    Intent shared (IS),
                    intent exclusive (IX),
                    shared with intent exclusive (SIX).                  


10. Ques:  What are the different types of replication supported by SQL SERVER ?
Answer:
There are three types of replication  supported by SQL SERVER:

Snapshot Replication. Snapshot Replication takes snapshot of one database and moves it to the other database. After initial load data can be refreshed periodically. The only disadvantage of this type of replication is that all data has to be copied each time the table is refreshed.

Transactional Replication In transactional replication data is copied first time as in snapshot replication, but later only the transactions are synchronized rather than replicating the whole database.You can either specify to run continuously or on periodic basis.

Merge Replication. Merge replication combines data from multiple sources into a single central database.Again as usual the initial load is like snapshot but later it allows change of data both on subscriber and publisher, later when they come on-line it detects and combines them and updates accordingly.


Thursday, 16 February 2017

ASP.NET interview questions Part-3

1. Ques: What is serialization ? What is uses for serialization ?
Answer:
Serialization is the process of converting an object into a stream of bytes in order to store the object or transmit it to memory, a database, or a file.

Uses for serialization as given bellow
  • Storing user preferences in an object.
  • Maintaining security information across pages and applications.
  • Modification of XML documents without using the DOM.
  • Passing an object from on application to another.
  • Passing an object from one domain to another.
  • Passing an object through a firewall as an XML string. 

2. Ques: What is difference between XML Serialization and Binary Serialization ?
Answer:
XML Serialization:
  • XML serialization is serializing an object into an XML file.
  • It use namespace named System.Xml.Serialization. 
  • XML Serialization is more efficient and fast than Binary Serialization.
  • Xml is more interoperable and human readable than binary.
  • Xml Serializer need not mention serializable attribute on the class.
Binary Serialization:
  • Binary serialization is  serializing an object into a Binary file.
  • It use namespace System.RunTime.Serialization.Formatters.Binary.
  • Binary Serialization is more efficient and fast than XML Serialization.
  • Binary serializer need serializable attribute.     

3. Ques: What is of Globalization and Localization in ASP.NET? 
Answer :
Globalization is the process of designing the application for users of different languages across the Globe (multiple cultures). To do globalization we need to use Resource Files.

In Localization designing the application so that application behave as per the current culture and locale.

4. Ques: What is the App Domain in ASP.NET? What are the features of App Domain.
Answer :
App Domain is Lightweight process which is both a container and boundary. it is logical isolation boundary created around .NET applications so that applications do not access or affect each other.
App Domains are generally created by Hosts for example Internet Explorer and Asp.net.

Application domains have the following features:
  • Better efficiency by executing long-running processes. 
  • It provides security by restricting the direct access code from one application to the code of another application.
  • Reliability by using isolation of tasks.
  • App Domain makes the boundary for code safety.
  • Each app domain runs on its own security level.

5. Ques: What is the authentication in ASP.NET? 
Answer :
Authentication is the process of determining the authenticity of a user based on the user’s credentials.
ASP.NET provides three ways to authenticate a user:

Forms authentication: This authentication mode is cookies based authentication, where the user name and the password are stored either in a text file or the database
<configuration>
    <system.web>    
    <authentication mode="Forms">
    <forms loginUrl="login.aspx">
        <credentialspasswordFormat="Clear">
            <user name="admin" password="admin!@#" />
        </credentials>
    </forms>
    </authentication>        
    <authorization>
    </system.web>
</configuration>

Windows authentication: It authenticates users based on the users' Windows accounts.
<authentication mode="Windows"/>
<authorization>
<allow users ="*" />
</authorization>

Passport authentication: Passport authentication is a centralized authentication service that uses Microsoft's Passport Service to authenticate the users of an application.

<configuration>
  <system.web>
    <authenticationmode="Passport">
      <passportredirectUrl="login.aspx" />
    </authentication>
    <authorization>
      <deny users="?" />
    </authorization>
  </system.web>
</configuration>


6. Ques: What is Authorization in ASP.NET? 
Authorization is provide the accessibility to a resource for a authenticated user. authorization can only work with authenticated users.
Three types of authorization in ASP.NET.

  • 1. URL Authorization
  • 2. File Authorization
  • 3. Authorization based on ACLs

7. Ques: What is an Impersonation?
Answer:
  • It is the process of executing code in the context of another user identity.
  • It is the mechanism in the ASP.NET which decide under which account web application should be run.
  • By default Impersonation is off, we need to enable it in Web.config file.
  • By default all the ASP.NET applications run under the ASP.NET user account. If you set the impersonation to TRUE in the Web.config file then that application runs under the current user's account who has logged in that machine. <identity impersonate="true" /> 
We can use the impersonation in this two scenarios:
  • To give each web application different permissions.
  • To use existing Windows user permission.

8. Ques: How Can you change a Master Page dynamically at runtime?
Answer:
Yes. To change a master page, set the MasterPageFile property to point to the .master page during the PreInit page event.


9. Ques:  How many web.config files can I have in an application?
Answer:
You can keep multiple web.config files in an application. You can place a Web.config file inside a folder or wherever you need (apart from some exceptions) to override the configuration settings that are inherited from a configuration file located at a higher level in the hierarchy.


10. Ques: What are Themes?
Themes are made up of skins, cascading style sheets (CSS), images, and other resources, and they are created within special folders in the server structure. Themes are like CSS styles - they both define a set of common attributes that can be applied to controls and elements on any page, however CSS is limited to the presentation elements of a control. Themes allow the customisation of any property of an Asp.net control, such as text values, icon glyphs, template layouts and so on.

Oops concept questions Part-3

1. Ques: Difference between association, aggregation and composition ?
Answer:
  • Association: Association is a relationship where all objects have their own life cycle and there is no owner.
Let's take an example of Teacher and Student. Multiple students can associate with single teacher and single student can associate with multiple teachers, but there is no ownership between the objects and both have their own life cycle. Both can be created and deleted independently.
  • Aggregation: Aggregation is a specialized form of Association where all objects have their own life cycle, but there is ownership and child objects can not belong to another parent object.
Let's take an example of Department and teacher. A single teacher can not belong to multiple departments, but if we delete the department, the teacher object will not be destroyed. We can think about it as a “has-a” relationship.
  • Composition: Composition is again specialized form of Aggregation and we can call this as a “death” relationship. It is a strong type of Aggregation. Child object does not have its life cycle and if parent object is deleted, all child objects will also be deleted.
Let's take again an example of relationship between House and Rooms. House can contain multiple rooms - there is no independent life of room and any room can not belong to two different houses. If we delete the house - room will automatically be deleted.


2. Ques: What are the advantages of Property in class ?
Answer:
  • Properties  are useful for data binding.
  • Properties are used to restrict direct access to member variables of a class.
  • Setting property may require certain validation, and validation code in "Set" part of code can easily help you validate the input and report errors accordingly.
  • Set part of method can raise notification events such as INotifyPropertyChanged.PropertyChanged which other objects can listen for and update the display value.

3. Ques: What is difference between Generalization and Specialization ?
Answer:
Generalization:-
The process of extracting common characteristics from two or more classes and combining them into a generalized superclass, is called generalization.

Specialization:-
Specialization is the reverse process of generalization means creating new sub classes from an existing class.




4. Ques: What is static constructor ? What are the properties of static constructors.
Answer:
A static constructor is used to initialize any static data.
It is called automatically before the first instance is created or any static members are referenced.

Static constructors have the following properties:
  • A static constructor does not take access modifiers or have parameters.
  • A static constructor is called automatically to initialize the class before the first instance is created or any static members are referenced.
  • A static constructor cannot be called directly.
  • The user has no control on when the static constructor is executed in the program.
  • A typical use of static constructors is when the class is using a log file and the constructor is used to write entries to this file.
  • Static constructors are also useful when creating wrapper classes for unmanaged code, when the constructor can call the LoadLibrary method.

5. Ques: What is Private constructor ? When we are using Private constructor.
Answer:
Private constructors are used to prevent creating instances of a class.
It is used in singleton design patterns, where the code only one instance of a class can ever be created.
When we declare a class constructor as private , we can not do 2 things:-
  • We can not inherit the class.
  • We can not create a object of the class.

6. Ques:  How can we implement singleton pattern in .NET?
Answer:
Singleton pattern restricts only one instance running for an object.
Singleton pattern is commonly used in print spoolers.

Following three steps needed to implement singleton pattern
  • A class with static members needs to be created.
  • A private constructor to the class above should be defined. 
  • A static method can be used to access the singleton object.
Public class SampleStaticClass
        Private shared objemployee as clsemployee
End class
 

7. Ques:  What is Inheritance ? Explain different types of Inheritance ? Answer:
Taking the properties of one class into another class is called inheritance. Inheritance provides
reusability by allowing us to extend an existing class. The reason behind OOP programming is
to promote the reusability of code and to reduce complexity in code and it is possible by
using inheritance.

There are four types of Inheritance in Object oriented programming.

  • Single Inheritance : contains one base class and one derived class
  • Hierarchical Inheritance : Contains one base class and multiple derived classes of same base class
  • Multilevel Inheritance : Contains a class derived from a derived class
  • Multiple Inheritance : Contains several base class and a derived class