Thursday, 9 July 2015

DOT NET Interview Part-1

 Interview Question answers For Experienced Developers

What do I need to create and run an ASP.NET application?
· Windows 2000, Windows Server 2003 or Windows XP.
· ASP.NET, which can be either the redistributable
(included in the .NET SDK) or Visual Studio .NET.

Where can I download the .NET SDK?
.NET SDK can be obtained here.
(You have to install the Microsoft .NET Framework Version 1.1 Redistributable Package
before installing the .NET SDK.)

2. Are there any free IDEs for the .NET SDK?
· Microsoft provides Visual Studio 2005 Express Edition Beta for free. Of particular interest to the ASP.NET developers would be the Visual Web Developer 2005 Express Edition Beta 2 available as a free download.
· The ASP.NET Web Matrix Project (supported by Microsoft) is a free IDE for developing ASP.NET applications and is available here.

· There is also a free open-source UNIX version of the  Microsoft .NET development platform called Mono available for download here.

· Another increasingly popular Open Source Development Environment for .NET is the #develop (short for SharpDevelop) available for download here.

2. When was ASP.NET released?

ASP.NET is a part of the .NET framework which was released as a software platform in 2002.

4. Is a new version coming up?

ASP.NET 2.0, Visual Studio 2005 (Whidbey), Visual Web Developer 2005 Express Editionare the next releases of Microsoft's Web platform and tools.
They have already been released as Beta versions. They are scheduled to be
released in the week of November 7, 2005.

5. Explain Namespace.


Namespaces are logical groupings of names used within a program. There may be multiple
namespaces in a single application code, grouped based on the identifiers’ use.
The name of any given identifier must appear only once in its namespace.

6. List the types of Authentication supported by ASP.NET.
· Windows (default)
· Forms
· Passport
· None (Security disabled)

7. What is CLR?


Common Language Runtime (CLR) is a run-time environment that manages the execution of
.NET code and provides services like memory management, debugging, security,
etc. The CLR is also known as Virtual Execution System (VES).

8. What is CLI?


The CLI is a set of specifications for a runtime environment, including a common type
system, base class library, and a machine-independent intermediate code known
as the Common Intermediate Language (CIL). (Source: Wikipedia.)

9. List the various stages of Page-Load lifecycle.
· Init()
· Load()
· PreRender()
· Unload()
10. Explain Assembly and Manifest.

An assembly is a collection of one or more files and one of them (DLL or EXE) contains a special metadata called Assembly Manifest. The manifest is stored as binary data and contains details like versioning requirements for the assembly, the author, security permissions, and list of files forming the assembly. An assembly is created whenever a DLL is built. The manifest can be viewed
programmatically by making use of classes from the System.Reflection namespace. The tool Intermediate Language Disassembler (ILDASM) can be used for this purpose. It can be launched from the command prompt or via Start> Run.

11. What is Shadow Copy?


In order to replace a COM component on a live dedicated server, it was necessary to stop the entire website, copy the new files and then restart the website. This is not feasible for the web servers that need to be always running. .NET components are different. They can be overwritten at any time using a mechanism called Shadow Copy. It prevents the Portable Executable (PE) files like DLLs and EXEs from being locked. Whenever new versions of the PEs are released, they are automatically detected by the CLR and the changed components will be automatically loaded. They will be used to process all new requests not currently executing, while the older version still runs the
currently executing requests. By bleeding out the older version, the update is  completed.

12. What is DLL Hell?


DLL hell is the problem that occurs when an installation of a newer application might  break or hinder other applications as newer DLLs are copied into the system and the older applications do not support or are not compatible with them. .NET overcomes this problem by supporting multiple versions of an assembly at any given time. This is also called side-by-side component versioning.

13. Explain Web Services.


Web services are programmable business logic components that provide access to  functionality through the Internet. Standard protocols like HTTP can be used to access them. Web services are based on the Simple Object Access Protocol (SOAP), which is anapplication of XML. Web services are given the .asmx extension.
14. Explain Windows Forms.

Windows Forms is employed for developing Windows GUI applications. It is a class  library that gives developers access to Windows Common Controls with rich functionality. It is a common GUI library for all the languages supported by the .NET Framework.

15. What is Postback?

When an action occurs (like button click), the page containing all the controls within  the
tag performs an HTTP POST, while having itself as the target URL. This is called Postback.

16. Explain the differences between server-side and client-side code?

Server side scripting means that all the script will be executed by the server and interpreted as needed. Client side scripting means that the script will be executed immediately in the browser such as form field validation, clock, email validation, etc. Client side scripting is usually done in VBScript or JavaScript. Since the code is included in the HTML page, anyone can see the code by viewing the page source. It also poses as a possible security hazard for the client computer.

17. Enumerate the types of Directives.
· @ Page directive
· @ Import directive
· @ Implements directive
· @ Register directive
· @ Assembly directive
· @ OutputCache directive
· @ Reference directive
18. What is Code-Behind?


Code-Behind  is a concept where the contents of a page are in one file and the server-side
code is in another. This allows different people to work on the same page at the same time and also allows either part of the page to be easily redesigned,with no changes required in the other. An Inherits attribute is added to the @Page directive to specify the location of the Code-Behind file to the ASP.NET page.

19. Describe the difference between inline and code behind.

Inline code is written along side the HTML in a page. There is no separate distinction between design code and logic code. Code-behind is code written in a separate file and referenced by the .aspx page.

20. List the ASP.NET validation controls?
· RequiredFieldValidator
· RangeValidator
· CompareValidator
· RegularExpressionValidator
· CustomValidator
· ValidationSummary
21. What is Data Binding?


Data binding is a way used to connect values from a collection of data (e.g. DataSet) to the controls on a web form. The values from the dataset are automatically displayed in the controls without having to write separate code to display them.

22. Describe Paging in ASP.NET.

The DataGrid control in ASP.NET enables easy paging of the data. The AllowPagingproperty of the DataGrid can be set to True to perform paging. ASP.NET automatically performs paging and provides the hyperlinks to the other pages in different styles, based on the property that has been set for PagerStyle.Mode.

23. Should user input data validation occur server-side or client-side? Why?

All userinput data validation should occur on the server and minimally on the client-side, though it is a good way to reduce server load and network traffic because we can ensure that only data of the appropriate type is submitted from the form. It is totally insecure. The user can view the code used for validation and create a workaround for it. Secondly, the URL of the page that handles the data is freely visible in the original form page. This will allow unscrupulous users to send data from their own forms to your application.Client-side validation can sometimes be performed where deemed appropriate and feasible to provide a richer, more responsive experience for the user.

24. What is the difference between Server.Transfer and Response.Redirect?
· Response.Redirect: This tells the browser that the requested page can be found at a new location. The browser then initiates another request to the new page loading its contents in the browser. This results in two requests by the browser.
· Server.Transfer: It transfers execution from the first page to the second page on the server. As far as the browser client is concerned, it made one request and the initial page is the one responding with content.The benefit of this approach is one less round trip to the server from
the client browser. Also, any posted form variables and query string parameters are available to the second page as well.
25. What is an interface and what is an abstract class?
In an interface, all methods must be abstract (must not be defined). In an abstract class, some methods can be defined. In an interface, no accessibility modifiers are allowed, whereas it is allowed in abstract classes.

26. Session state vs. View state:

In some cases, using view state is not feasible. The alternative for view state is session state. Session state is employed under the following situations:Large amounts of data - View state tends to increase
· the size of both the HTML page sent to the browser and the size of form  posted back. Hence session state is used.
· Secure data - Though the view state data is encoded and may be encrypted, it is better and secure if no sensitive data issent to the client. Thus, session state is a more secure option.
· Problems in serializing of objects into view state - View state is efficient for a small set of data. Other types like DataSet are slower and can generate a very large view
state.
26. Can two different programming languages be mixed in a  single ASPX file?

ASP.NET’s built-in parsers are used to remove code from ASPX files and create temporary
files. Each parser understands only one language. Therefore mixing of languages in a single ASPX file is not possible.

28. Is it possible to see the code that ASP.NET generates from an ASPX file?

By enabling debugging using a <%@ Page Debug="true" %> directive
in the ASPX file or a statement in Web.config, the generated code can be viewed. The code is stored in a CS or VB file (usually in the\%SystemRoot%\Microsoft.NET\Framework\v1.0.nnnn\Temporary
ASP.NET Files).

29. Can a custom .NET data type be used in a Web form?

This can be achieved by placing the DLL containing the custom data type in the application root's bin directory and ASP.NET will automatically load the DLL when the type is referenced.

30. List the event handlers that can be included in Global.asax?

· Application start and end event handlers
· Session start and end event handlers
· Per-request event handlers
· Non-deterministic event handlers
31. Can the view state be protected from tampering?

This can be achieved by including an @ Page directive with anEnableViewStateMac="true" attribute in each ASPX file that has to be protected. Another way is to include the /> statement in the Web.config file.

32. Can the view state be encrypted?

The view  state can be encrypted by setting EnableViewStateMac to true and either modifying the element in Machine.config to or by adding the above statement to Web.config.

33. When during the page processing cycle is ViewState available?


The view state is available after the Init() and before the Render() methods are called during Page load.
34. Do Web controls support Cascading Style Sheets?

All Web controls inherit a property named CssClass from the base classSystem.Web.UI.WebControls.WebControl which can be used to control the properties of the web control.

35. What namespaces are imported by default in ASPX files?

The following namespaces are imported by default. Other namespaces must be imported
manually using @ Import directives.
· System
· System.Collections
· System.Collections.Specialized
· System.Configuration
· System.Text
· System.Text.RegularExpressions
· System.Web
· System.Web.Caching
· System.Web.Security
· System.Web.SessionState
· System.Web.UI
· System.Web.UI.HtmlControls
· System.Web.UI.WebControls

35. What classes are needed to send e-mail from an ASP.NET application?

The classes MailMessage and SmtpMail have to be used to send email from an ASP.NET application. MailMessage and SmtpMail are classes defined in the .NET  Framework Class Library's System.Web.Mail namespace.

37. Why do some web service classes derive from System.Web.WebServices while others do not?

Those Web Service classes which employ objects like Application, Session, Context,
Server, and User have to derive from System.Web.WebServices. If it does not use these objects, it is not necessary to be derived from it.

38. What are VSDISCO files?

VSDISCO files are DISCO files that enable dynamic discovery of Web Services. ASP.NET
links the VSDISCO to a HTTP handler that scans the host directory and subdirectories for ASMX and DISCO files and returns a dynamically generated DISCO document. A client who requests a VSDISCO file gets back what appears to be a static DISCO document.

39. How can files be uploaded to Web pages in ASP.NET?

This can be done by using the HtmlInputFile class to declare  an instance of an tag. Then, a byte[] can be declared to read in the data  from the input file. This can then be sent to the server.

40. How do I create an ASPX page that periodically refreshes itself?

The following META tag can be used as a trigger to automatically refresh the page every n seconds:

http-equiv="Refresh" content="nn">

NEXT

WCF Interview Question Ansers KIT-2

26. What are Attached Properties in WPF?
Attached properties are basically Dependency Properties that allows the attachment of a value to any random object.

27. What is the INotifyPropertyChanged Interface?
The InotifyPropertyChanged notifies clients, generally those who are binding, if the value of a property gets changed. It has an event, called PropertyChanged, which gets raised everytime a property of Model object is changed.

28. What is the basic difference between Events and Commands in the MVVM Model?
Commands are more powerful and are advantageous to use instead of events. Actions are deeply connected with the event’s source and, therefore, the events cannot be reused easily. But commands make it possible to efficiently maintain multiple actions at one place and then reuse them as per our requirement.

29. What is the method to force close a ToolTip, which is currently visible?
It can be closed by setting the tooltip’s IsOpen property to false.

30. Write the differences between DynamicResource and StaticResource.
The most basic difference is that StaticResource evaluates the resource one time only, but DynamicResource evaluates it every time the resource is required. And due to this reason, DyanamicResource is heavy on the system but it makes pages or windows load faster

31. Explain MVVM pattern.
MVVM pattern divides the UI code into 3 basic parts:
·          Model – It represents a set of classes, which contain data received from databases.
·          View – It is the code that agrees with the visual representation of the data.
·          ViewModel – It is the layer that binds View and Model together. It presents this data in a manner, which is easy to understand. It also controls how View interacts with the application.

32. Why are layout panels needed for in WPF?
Layout Panels are needed so that the controls fit screens of different sizes or having different font sizes. If we arrange controls on fixed pixel coordinates, then this model will fail when moved to a different environment. For this reason, Layout panels are necessary.

33. Write about UserControl in brief.
UserControl wraps existing controls into a single reusable group. It contains a XAML file and a code. UserControl cannot be styled or templated.

34. What is the way to determine if a Freezable object is Frozen?
“IsFrozen” property of the object can be used to determine if the freezable object is frozen.

35. What is the unit of measurement in WPF?
All measurements are made in device-independent pixels, or logical pixels. One pixel is 1/96th part of an inch. These logical pixels are always mentioned as double, this enables them to have a fractional value too.

36. What is an adorner?
They are a special kind of FrameworkElement that provide visual clues to the user. They are also used to add handles to elements and give information about the state of a control. Adorners are bound to the UIElement and are rendered on a surface that lies above the element, which is adorned. This surface is called an AdornerLayer. Adorners are mostly placed relatively to the bounded element.

37. Explain Serialization?
It is the process of converting the state of an object to stream of bytes.

38. Is MDI supported in WPF?
MDI is not supported in WPF. UserControl can be used to give the same functionality as MDI.

39. What is XBAP?
XBAP is the abbreviated form of XAML Browser Application. It allows WPF applications to run inside web browsers. Installation of .NET framework on the client machine is a prerequisite for running WPF applications. But hosted applications are not given full admission to the client’s machine and are executed in a sandbox environment. Using WPF, such applications can also be created, which run directly in the browser. These applications are called XBAP.

40. In what sense are WPF and Silverlight similar?
Silverlight and WPF are similar in the sense that they both use XAML and share the same code, syntax and libraries.

41. How to make a ToolTip appear while hovering over a disabled element?
For this purpose, the ShowOnDisabled property can be used. It belongs to the ToolTipService class.

42. How can ListBox be made to scroll smoothly?
ListBox is configured to scroll on an item-by-item basis by default. This is dependent on the height of each element and the scrolling action, thus, giving a rough feeling. Better way is to configure scrolling action so that it shifts items by a few pixels irrespective of their height. This is done by setting the ScrollViewer.CanContentScroll property to “false”. This will, however, make the ListBox lose the virtualization property.

43. Where does the execution start in a WPF application?
WPF applications created in Visual Studio run without a Main method. This is because the applications are special-cased when they are compiled from XAML. That means, Visual Studio attaches a Build Action of ApplicationDefinition to the XAML file. This results in the auto generation of a Main method.

44. Can Windows Service be created Using WPF?
No, Windows Services cannot be created using WPF. WPF is a presentation language. Windows services need specific permissions to execute some GUI related functions. Therefore, if it does not get the required permissions, it gives errors.

45. What are the different kinds of Routed events in WPF?
There are three types of Routed events in WPF. They are:
·          Direct – This event can only be raised by the element in which it was originated.
·          Tunneling – This event is first raised by the element in which it was originated and then it gets raised by each consecutive container in the visual tree.
·          Bubbling – This event is first raised by the uppermost container in the visual tree and then gets raised by each consecutive container lying below the uppermost one, till it reaches the element it where it was originated.

46. Why is it better to wrap items in ComboBoxItem?
It has some important properties like IsSelected and IsHighlighted and also some necessary events like Selected and Unselected. ComboBoxItem is a content control and is thus very useful for adding simple strings to a ComboBox.

 47. How to get Automation IDs of items in a ItemsControl?
The best way to do this is by setting it Name property as it is utilized for automation purposes by default. But if you require to give an ID to an element, other than it’s name, then the AutomationProperties.AutomationID property can be set as per need.

 48. How can command-line arguments be retrieved in a WPF application?
The most preferred method for this is to call System.Environment.GetCommandLineArgs at any random point in the application.

49. State the name of the classes, which contain arbitrary content.
Content Control
HeaderedContent Control
Items Control
HeaderedItems Control

50. Which NameSpace has ‘Popup’ and ‘Thumb’ controls?
The namespace system.windows.controls.primitives has ‘Popup’ and ‘Thumb’ controls.

WCF interviews KIT Part-1


1. What is WPF?
WPF is the latest presentation API by Microsoft Windows. It is 2D and 3D graphic engine. Its capabilities include:-
·          All the common user controls. For example, check boxes, buttons, sliders etc.
·          Supports flow and fix format documents
·          all the functionality of Flash and HTML
·          Data binding
·          Multimedia
·          Animation

2. What are the types of documents supported by WPF?
Two types of the documents supported by Windows Presentation Foundation (WPF) are the Flow format and fixed Format document. Flow format document alters the content to fit the screen size while fixed format document present content irrespective of the screen size.

3. Name the namespace required for working with 3D.
The namespace required for working in 3D is System.Windows.Media.Medi3D.

4. Is it right to say that WPF has replaced DirectX?
No, WPF can never replace DirectX. WPF cannot be used to create games with stunning graphics. WPF is meant to be a replacement for windows form, not DirectX.

5. What are dependency properties?
Properties that belong to a specific class but can be used for another are called the dependency properties.

6. How can the size of StatusBar be increased proportionally?
By overruling the ItemsPanel attribute of StatusBar with a grid. The grid’s columns can be appropriately configured to get the desired result.

7. What are Freezable objects in WPF?
An object, which has its state locked down, so that it becomes unchangeable, is known as a freezable object. Such objects perform better. It is also safer if they are required to be shared between threads. 
8. Why should WPF be preferred over Adobe Flash?
WPF is a more recent technology and thus has the latest development tools. It supports a broader range of programming languages and has a robust control reuse.

 9. How is Silverlight different from WPF browser application?
One of the major differences is that .NET framework is required for running WPF browser applications on the client machine. But Silverlight runs using only the plug-in. Another point of difference is that applications made in WPF depend on the OS as .NET Framework only runs on Windows. On the other hand, the Silverlight plug-in can be installed on those OSs also, which are not Windows.

10. Name the methods present in the DependencyObject.
It has three objects, namely:
·          SetValue
·          ClearValue
·          GetValue

11. Write about PRISM.
PRISM is a framework for creating complex applications for WPF, Silverlight or Windows Phone. PRISM utilizes MVVM, IC, Command Patterns, DI and Separation of Concerns to get loose coupling.

12. Is it possible to use Windows Forms in a WPF application?
Yes, Windows form can be used in WPF. Windows form can appear as a WPF pop. The controls of this Window form can be placed besides WPF controls in a WPF page by utilizing the functions of the WindowsFormsHost control that comes preinstalled.

13. Describe CustomControl briefly.
CustomControl widens the functions of existing controls. It consists of a default style in Themes/Generic.xaml and a code file. It is the best way to make a control library and can also be styled or templated.

 14. Name the common assemblies used in WPF?
·          PresentationFoundation
·          WindowsBase
·          PresentaionCore

15. Define Path animations in WPF
Path animation is a type of animation in which the animated object follows a path set by the Path geometry.

16. Can WPF applications be made without XAML?
Yes WPF applications can be created without XAML as using XAML in WPF is a matter of choice.

 17. What are the types of windows in WPF?
WPF has three types of windows:
·          Normal Window
·          Page Window
·          Navigate Window

18. How can elements in a ListBox be sorted?
Sorting can be done by using a property of the ItemsCollection object. ItemsCollection contains an attribute, SortDescriptions, which holds System.ComponentModel.SortDescription instances. Every SortDescription instance defines how the elements should be sorted and indicates if the sort is descending or ascending.
For instance, this code sorts elements of ContentControl on the basis of their word count property:
myItemsControl.Items.SortDescriptions.Add(new SortDescription(“WordCount”, ListSortDirection.Descending));

19. How is MVVM different from MVC?
MVC stands for Model-View Controller and.MVVM stands for Model-View ViewModel.
In MVVM, View Model is used instead of a controller. This View Model is present beneath the UI layer. It reveals the command objects and data that the view requires. It acts like a container object from which view gets its actions and data.

20. Explain Routed events in WPF.
An event, which can invoke handlers on more than one listeners present in an element tree, instead of the single object which called the event, is known as a Routed event.

21. How is System.Windows.Media.Visual dll utilized in WPF?
It is used whenever a requirement for creating custom user interface arises. It is a drawing object, which gives instructions for making an object. These instructions include opacity etc. of the drawing. The Visual class also bridges the functionalities of WPF managed classes and the MilCore.dll.

22. What are the various layout panels in WPF?
They are:
·          Stack Panel
·          Grid Panel
·          Canvas Panel
·          Dock Panel
·          Wrap Panel


23. Name the important subsystems in WPF
The major subsystems are:
·          Windows.Controls.Control
·          Windows.DependancyObject
·          Windows.FrameworkElement
·          Windows.Media.Visuals
·          Object
·          Threading.DispatcherObject
·          Windows.UIElements

24. What does BAML mean in WPF?
BAML is the abbreviation for Binary Application Markup Language. It is nothing but XAML that has been tokenized, parsed and changed into binary form. BAML is a compressed declarative language, which gets loaded and parsed quicker than XAML.

 25. What is Difference between Page and Window Controls in WPF?
The basic difference is that Window Control presides over Windows Application while Page Control presides over the hosted Browser Applications. Also, Window control may contain Page Control, but the reverse cannot happen.

Previous                                                                                                                             Next Part-2