DotNetSlackers: ASP.NET News for lazy Developers

Monday, August 31, 2015

.NET Framework - .NET Questions and Answers for Interview

  1. What is Common Language Specification (CLS)?                                                                        CLS is a set of basic rules, which must be followed by each .NET language to be a .NET- compliant language. It enables interoperability between two .NET-compliant languages. CLS is a subset of CTS; therefore, the languages supported by CLS can use each other's class libraries similar to their own. Application programming interfaces (APIs), which are designed by following the rules defined in CLS can be used by all .NET-compliant languages.                                                     
  2. What is the role of the JIT compiler in .NET Framework?                                                      The JIT compiler is an important element of CLR, which loads MSIL on target machines for execution. The MSIL is stored in .NET assemblies after the developer has compiled the code written in any .NET-compliant programming language, such as Visual Basic and C#.                                                       JIT compiler translates the MSIL code of an assembly and uses the CPU architecture of the target machine to execute a .NET application. It also stores the resulting native code so that it is accessible for subsequent calls. If a code executing on a target machine calls a non-native method, the JIT compiler converts the MSIL of that method into native code. JIT compiler also enforces type-safety in runtime environment of .NET Framework. It checks for the values that are passed to parameters of any method.                                                                                                                                  For example, the JIT compiler detects any event, if a user tries to assign a 32-bit value to a parameter that can only accept 8-bit value.
  3. Describe the roles of CLR in .NET Framework.                                                                        CLR provides an environment to execute .NET applications on target machines. CLR is also a common runtime environment for all .NET code irrespective of their programming language, as the compilers of respective language in .NET Framework convert every source code into a common language known as MSIL or IL (Intermediate Language).                                                                                             CLR also provides various services to execute processes, such as memory management service and security services. CLR performs various tasks to manage the execution process of .NET applications.

    The responsibilities of CLR are listed as follows:
    • Automatic memory management
    • Garbage Collection
    • Code Access Security
    • Code verification
    • JIT compilation of .NET code

  4. What is the difference between int and int32.                                                                     There is no difference between int and int32. System.Int32 is a .NET Class and int is an alias name forSystem.Int32.
  5. What are the improvements made in CAS in .NET 4.0?
    The CAS mechanism in .NET is used to control and configure the ability of managed code. Earlier, as this policy was applicable for only native applications, the security guarantee was limited. Therefore, developers used to look for alternating solutions, such as operating system-level solutions. This problem was solved in .NET Framework 4 by turning off the machine-wide security. The shared and hosted Web applications can now run more securely. The security policy in .NET Framework 4 has been simplified using the transparency model. This model allows you to run the Web applications without concerning about the CAS policies.                                                                                       As a result of security policy changes in .NET Framework 4.0, you may encounter compilation warnings and runtime exceptions, if your try to use the obsolete CAS policy types and members either implicitly or explicitly. However, you can avoid the warnings and errors by using the <NetFx40_LegacySecurityPolicy> configuration element in the runtime settings schema to opt into the obsolete CAS policy behavior.
  6. How many types of generations are there in a garbage collector?
    Memory management in the CLR is divided into three generations that are build up by grouping memory segments. Generations enhance the garbage collection performance. The following are the three types of generations found in a garbage collector:
    • Generation 0 - When an object is initialized, it is said to be in generation 0.
    • Generation 1 - The objects that are under garbage collection process are considered to be in generation 1.
    • Generation 2 - Whenever new objects are created and added to the memory, they are added to generation 0 and the old objects in generation 1 are considered to be in generation 2.

  7. What technologies are being used in AJAX?
    AJAX uses four technologies, which are as follows:
    • JavaScript
    • XMLHttpRequest
    • Document Object Model (DOM)
    • Extensible HTML (XHTML) and Cascading Style Sheets (CSS)

  8.  What is Language Integrated Query (LINQ)?
    LINQ is a programming model that is the composition of general-purpose standard query operators that allow you to work with data, regardless of the data source in any .NET based programming language. It is the name given to a set of technologies based on the integration of query capabilities into any .NET language.                                                                                     
  9. In which statement the LINQ query is executed?
    A LINQ query is executed in the For Each statement in Visual Basic and in the foreach statement in C#.                                                                                                     
  10. Write the basic syntax of a LINQ query in Visual Basic as well as in C#.
    In Visual Basic, the basic syntax of a LINQ query starts with the From clause and ends with the Select or Group Byclause. In addition, you can use the WhereOrder By, and Order By Descending clauses to perform additional functions, such as filtering data and generating the data in a specific order.

    In C#, the basic syntax of a LINQ query starts with the From clause and ends with the Select or group by clause. In addition, you can use the whereorderby, and Orderby descending clauses to perform additional functions, such as filtering data and generating the data in a specific order.                                                                                                                
  11.  What are the different implementations of LINQ?
    The different implementations of LINQ are:
    • LINQ to SQL - Refers to a component of.NET Framework version 3.5 that provides a run-time infrastructure to manage relational data as objects.
    • LINQ to DataSet - Refers to a component that makes it easier and faster to query over data cached in a DataSet object.
    • LINQ to XML - Provides an in-memory XML programming interface.
    • LINQ to Objects - Refers to the use of LINQ queries with any IEnumerable or IEnumerable(T) collection directly, without the use of an intermediate LINQ provider or API, such as LINQ to SQL or LINQ to XML.

  12. What is the difference between the Select clause and SelectMany() method in LINQ?
    Both the Select clause and SelectMany() method are used to produce a result value from a source of values. The difference lies in the result set. The Select clause is used to produce one result value for every source value. The result value is a collection that has the same number of elements from the query. In contrast, the SelectMany() method produces a single result that contains a concatenated collection from the query.                                                                       
  13. What are the different Visual Basic features that support LINQ?
    Visual Basic includes the following features that support LINQ:
    • Anonymous types - Enables you to create a new type based on a query result.
    • Implicitly typed variables - Enables the compiler to infer and assign a type when you declare and initialize a variable.
    • Extension method - Enables you to extend an existing type with your own methods without modifying the type itself.
  14. What is a host process?
    A host process is an executable program that hosts a workflow. It may be a Windows Forms application, a Web application, or a Web service application. You can use Web services in the host process or remoting to enable other applications to communicate with the workflow.                        
  15. What are runtime services?
    Runtime services consist of predefined and user-defined classes that are available to the workflow runtime engine during execution to customize the behavior of workflow runtime. Some of the runtime services available in WF 4.0 are as follows:
    • Scheduling services - Enable creating and scheduling new workflow instances for execution.
    • Work batch services - Enable behavior to maintain a stable and consistent execution environment.
    • Persistence services - Enable you to save or restore the state of a running workflow for later use. You can restart the saved workflow anytime in future, even after weeks of inactivity.
    • Tracking services - Enable you to monitor the state of the workflows. This is particularly useful when you have multiple workflows active at the same time (for example, in a shopping cart application).
    • Timer service - Manages the timing required by the DelayActivity activity.
    • Transactions services - Provide the transaction support needed for data integrity.
    • Data exchange services - Manage custom communication services.
    • Threading services - Administer physical threads used to execute workflow instances.  

  16. Explain Custom Activities.
    In addition to the standard activities available within the base activity library, you can create new activities to meet specific business needs. Creating custom activities may be required to support a particular application that you want to integrate with WF. Custom activities are generally created through attributes and inheritance. You can create two types of custom activities, base and composite. You can create basic custom activity by inheriting the Activity class and custom composite activity by inheriting the compositeActivity class or a derived type.                          
  17.  What is cloud computing?
    The cloud computing is the computing which is completely based on the Internet. It can also be defined as the next stage in the evolution of the Internet. The cloud computing uses the cloud (Internet) that provides the way to deliver the services whenever and wherever the user of the cloud needs. Companies use the cloud computing to fulfill the needs of their customers, partners, and providers. The cloud computing includes vendors, partners, and business leaders as the three major contributors. The vendors are the one who provide applications and their related technology, infrastructure, hardware, and integration.

    The partners are those who offer cloud services demand and provide support service to the customers. The business leaders are the ones who use or evaluate the cloud service provided by the partners. The cloud computing enables the companies to treat their resources as a pool and not as independent resources.                                                                                                     
  18. What are Windows services?
    Windows services, previously known as NT services, are applications that are installed on the system as system services. In other words, Windows services are applications that run in the background with the Windows operating system. The primary use of Windows services is to reduce the consumption of memory required for performing backend operations. Let's take an example to understand this easily. Suppose you want to perform a variety of functions, such as monitor the performance of your computer or application, check the status of an application, and manage various devices, such as printers.

    In such a case, you can use Windows services to reduce memory consumption. In addition, Windows services can run on your system even if you have not logged on to your computer. In addition, these services do not have any user interface.                                                                
  19. Describe the services that UDDI provides to Web applications.
    UDDI provides the following types of services to a Web application:
    • XML Schema for business descriptions - Includes information about the service publisher (contact name, address, and so on) and specifications on the Web service
    • Web registry of Web services - Includes business, service, and binding information for the Web service                                                                                                                    
  20. Explain the WSDL.
    WSDL is a short form for Web Services Description Language, which is used to describe a Web service in terms of the messages that it creates and accepts. The WSDL document is an XML file that contains the interface schema for the Web service. It identifies the methods that are used during the exchange between a Web service consumer and a Web service provider. The following are the elements contained in the WSDL document:
    • Types - Describe the variations of data types that are used to exchange messages between the user and the provider.
    • Message - Describes the actual message or method call.
    • portType - Describes the set of operations and each related message.
    • binding - Describes the protocol details.
    • service - Used to make groups a set of related ports together.