.NET Apps Interview Questions
by Bhavya Sri, on Jun 13, 2017 10:15:31 AM
Q1. Why .NET Framework?Ans: .NET Framework is the most powerful development platform for building a variety of solutions on Windows. For example, using the .NET Framework, you can create applications for Windows Desktop, Web applications, Windows Phone applications, Windows Store applications, Windows Server, Windows Azure (cloud) as well as Bot frameworks and cognitive services.
Q2. What is BCL?
Ans: The Base Class Library is a Common Language Infrastructure. BCL encapsulates a large number of common functionalities which are available to all the .NET Languages. BCL makes the developers life much simpler while implementing various functionalities like I/O operations, Data access operations, graphical user interfaces and interfaces to various hardware devices by encapsulating them into various namespaces and classes. It also encapsulates the services which are required by the latest real world applications. .NET Framework applications, components and the controls are built on BCL.
Q3. Explain CLR, CTS, CLS under .NET Framework?
Ans: Common Language Runtime is one of the main building blocks of Microsoft .NET Framework which is responsible for performing various operations under .NET Framework.
When you design the application using Microsoft .NET languages like C#.NET or VB.NET, the language has its own complier which compiles the code into common format that is CIL [Common Intermediate Language]. Then CIL gets targeted to CLR which in turn performs many operations. It converts CIL into Native code with the help of JIT.
CLR also performs various other operations like Memory Management, Application Execution, Thread Management, Security checks, load the required assemblies and their types. The code which is managed by CLR is also known as Managed Code. All the managed languages are handled by a single runtime that is CLR.
Common Type System (CTS) defines how the types are defined and used in the Common Language Runtime. CTS provides cross-language integration, type safety, and high-performance code execution. -
When you define an integer variable in VB.NET and declare integer in C#.NET, both the languages share the same type which is Int32, available under .NET Framework.
CTS defines rules which must be followed by languages in order to make objects written in one language callable in other languages.
Microsoft .NET Framework provides various primitive data types which can be used while developing applications using various languages.
Common Language Specification (CLS) is a set of rules. CLS rules also define a subset of CTS. By defining components using CLS features only, developers are guaranteed to make use of these components in all the other languages which are CLS compliant languages. Most of the types which are defined under .NET framework are CLS complaint.
Q4. What is an application server?
Ans: As defined in Wikipedia, an application server is a software engine that delivers applications to client computers or devices. The application server runs your server code. Some well known application servers are IIS (Microsoft), WebLogic Server (BEA), JBoss (Red Hat), WebSphere (IBM).
Q5. What is a base class and derived class?
Ans: A class is a template for creating an object. The class from which other classes derive fundamental functionality is called a base class. For e.g. If Class Y derives from Class X, then Class X is a base class.
The class which derives functionality from a base class is called a derived class. If Class Y derives from Class X, then Class Y is a derived class.
Q6. What is an extender class?
Ans: An extender class allows you to extend the functionality of an existing control. It is used in Windows forms applications to add properties to controls.
Q7. What is inheritance?
Ans: Inheritance represents the relationship between two classes where one type derives functionality from a second type and then extends it by adding new methods, properties, events, fields and constants.
C# support two types of inheritance:
- Implementation inheritance
- Interface inheritance
Q8. What is implementation and interface inheritance?
Ans: When a class (type) is derived from another class(type) such that it inherits all the members of the base type it is Implementation Inheritance.
When a type (class or a struct) inherits only the signatures of the functions from another type it is Interface Inheritance.
In general Classes can be derived from another class, hence support Implementation inheritance. At the same time Classes can also be derived from one or more interfaces. Hence they support Interface inheritance.
Q9. What is inheritance hierarchy?
Ans: The class which derives functionality from a base class is called a derived class. A derived class can also act as a base class for another class. Thus it is possible to create a tree-like structure that illustrates the relationship between all related classes. This structure is known as the inheritance hierarchy.
Q10. How do you prevent a class from being inherited?
Ans: In VB.NET you use the NotInheritable modifier to prevent programmers from using the class as a base class. In C#, use the sealed keyword.
Q11. Name Different Types of Constructors in C#?
Ans: There are four different types of constructors you can write in a class -
- Default Constructor
- Parameterized Constructor
- Copy Constructor
- Static Constructor
Q12. Define Overriding?
Ans: Overriding is a concept where a method in a derived class uses the same name, return type, and arguments as a method in its base class. In other words, if the derived class contains its own implementation of the method rather than using the method in the base class, the process is called overriding.
Q13. Can you use multiple inheritance in .NET?
Ans: .NET supports only single inheritance. However the purpose is accomplished using multiple interfaces.
Q14. Why don’t we have multiple inheritance in .NET?
Ans: There are several reasons for this. In simple words, the efforts are more, benefits are less. Different languages have different implementation requirements of multiple inheritance. So in order to implement multiple inheritance, we need to study the implementation aspects of all the languages that are CLR compliant and then implement a common methodology of implementing it. This is too much of efforts. Moreover multiple interface inheritance very much covers the benefits that multiple inheritance has.
Q15. What is an Interface?
Ans: An interface is a standard or contract that contains only the signatures of methods or events. The implementation is done in the class that inherits from this interface. Interfaces are primarily used to set a common standard or contract.
Q16. What are events and delegates?
Ans: An event is a message sent by a control to notify the occurrence of an action. However it is not known which object receives the event. For this reason, .NET provides a special type called Delegate which acts as an intermediary between the sender object and receiver object.
Q17. What is business logic?
Ans: It is the functionality which handles the exchange of information between database and a user interface.
Q18. What is a component?
Ans: Component is a group of logically related classes and methods. A component is a class that implements the IComponent interface or uses a class that implements IComponent interface.
Q19. What is a control?
Ans: A control is a component that provides user-interface (UI) capabilities.
Q20. What are design patterns?
Ans: Design patterns are common solutions to common design problems.
Q21. What is a connection pool?
Ans: A connection pool is a ‘collection of connections’ which are shared between the clients requesting one. Once the connection is closed, it returns back to the pool. This allows the connections to be reused.
Q22. What is a flat file?
Ans: A flat file is the name given to text, which can be read or written only sequentially.
Q23. What are functional and non-functional requirements?
Ans: Functional requirements defines the behavior of a system whereas non-functional requirements specify how the system should behave; in other words they specify the quality requirements and judge the behavior of a system.
Functional - Display a chart which shows the maximum number of products sold in a region.
Non-functional – The data presented in the chart must be updated every 5 minutes.
Q24. What is an Assembly?
Ans: An assembly is a final deployable unit which can versioned and secured. The assembly can also be termed as a reusable collection of types and resources which work together as a logical unit of functionalities in .NET. .NET assemblies can be designed as executable (.EXE) or reusable component (.DLL). An assembly contains one or more managed types which can be made accessible to the unit or outside the unit.
Assembly gets divided into four different parts.
- Type Metadata.
- Intermediate Language.
Q25. Explain different types of Assemblies?
Ans: The different types of Assemblies are as follows:
Manifest - contains information about the assembly like Version of an assembly, the public key in case the assembly is shared assembly and the culture information. It also contains the security demands to verify this assembly. CLR uses the manifest to load the assembly.
Type Metadata - gives the complete information about the types which are available in the assembly like Class, Structure, Interface, Enum, and the methods, their parameters. The compilers automatically generate this metadata. You can make use of this Type Metadata to dynamically load the types using .NET Reflection.
Intermediate Language - It a code generated by the language specific compiler. It is also known as Machine independent code which can be compiled on one machine and can be deployed on another. CLR targets this code to JIT to convert it into processor depend on code which can be further executed.
Resources - Assembly can also contain the embedded resources like icons, images, string tables media clips.
You can see this information using a .NET framework utility called ILDASM.EXE
Microsoft .NET support different types of assemblies.
• Private Assembly - Private Assemblies are the assemblies which are only known to the application to which it has been referenced. By default, the assemblies are always private when you create and reference them. The private assembly gets stored in the application folder which is using the assembly.
Private assemblies are identified with the help of name of an assembly and version of an assembly. But the versions does not really come into the picture as the referenced assembly is in the same folder of your application.
• Shared/Global/Public Assembly - Global/Public Assemblies are the assemblies which are shared across multiple applications. These assemblies are installed into Global Assembly Cache which acts as a shared area for all the assemblies.
Global Assembly is identified with the four-part assembly name - Name of an Assembly, Version of an assembly, and Culture of an Assembly and Public Key Token of an assembly. Global Assembly Cache can contain different versions of an assembly.
You can install a public/global assembly into Global Assembly Cache [GAC] using GACUTIL.EXE tool.
• Satellite Assembly - Satellite Assemblies are used to build multi-lingual assemblies for applications. Satellite assemblies contain information about the cultures. Satellite assemblies are used to display the data in multiple languages according to Country/Region.
Q26. What is the global assembly cache (GAC)?
Ans: GAC is a machine-wide cache of assemblies that allows .NET applications to share libraries. GAC solves some of the problems associated with dll’s (DLL Hell).
Q27. What is a stack? What is a heap?
Ans: Stack is a place in the memory where value types are stored. Heap is a place in the memory where the reference types are stored.
Q28.What is instrumentation?
Ans: It is the ability to monitor an application so that information about the application’s progress, performance and status can be captured and reported.
Q29.What is code review?
Ans: The process of examining the source code generally through a peer, to verify it against best practices.
Q30. What is logging?
Ans: Logging is the process of persisting information about the status of an application.
Q31. What are mock-ups?
Ans: Mock-ups are a set of designs in the form of screens, diagrams, snapshots etc., that helps verify the design and acquire feedback about the application’s requirements and use cases, at an early stage of the design process.
Q32. What is a Form?
Ans: A form is a representation of any window displayed in your application. Form can be used to create standard, borderless, floating, modal windows.
Q33. What is a multiple-document interface(MDI)?
Ans: A user interface container that enables a user to work with more than one document at a time. E.g. Microsoft Excel.
Q34. What is a single-document interface (SDI) ?
Ans: A user interface that is created to manage graphical user interfaces and controls into single windows. E.g. Microsoft Word
Q35. What is BLOB ?
Ans: A BLOB (binary large object) is a large item such as an image or an exe represented in binary form.
Q36. What is ClickOnce?
Ans: ClickOnce is a new deployment technology that allows you to create and publish self-updating applications that can be installed and run with minimal user interaction.
Q37. What is object role modeling (ORM) ?
Ans: It is a logical model for designing and querying database models. There are various ORM tools in the market like CaseTalk, Microsoft Visio for Enterprise Architects, Infagon etc.
Q38. What is a private assembly?
Ans: A private assembly is local to the installation directory of an application and is used only by that application.
Q39. What is a shared assembly?
Ans: A shared assembly is kept in the global assembly cache (GAC) and can be used by one or more applications on a machine.
Q40. What is the difference between user and custom controls?
Ans: User controls are easier to create whereas custom controls require extra effort.
User controls are used when the layout is static whereas custom controls are used in dynamic layouts.
A user control cannot be added to the toolbox whereas a custom control can be.
A separate copy of a user control is required in every application that uses it whereas since custom controls are stored in the GAC, only a single copy can be used by all applications.
41.Where do custom controls reside?
In the global assembly cache (GAC).
Q42. What is a third-party control ?
Ans: A third-party control is one that is not created by the owners of a project. They are usually used to save time and resources and reuse the functionality developed by others (third-party).
Q43. What is a binary formatter?
Ans: Binary formatter is used to serialize and deserialize an object in binary format.
Q44. What is Boxing/Unboxing?
Ans: Boxing is used to convert value types to object.
E.g. int x = 1;
object obj = x ;
Unboxing is used to convert the object back to the value type.
E.g. int y = (int)obj;
Boxing/unboxing is quiet an expensive operation.
Q45. What is a COM Callable Wrapper (CCW)?
Ans: CCW is a wrapper created by the common language runtime(CLR) that enables COM components to access .NET objects.
Q46. What is a Runtime Callable Wrapper (RCW)?
Ans: RCW is a wrapper created by the common language runtime(CLR) to enable .NET components to call COM components.
Q47. What is a digital signature?
Ans: A digital signature is an electronic signature used to verify/gurantee the identity of the individual who is sending the message.
Q47. What is garbage collection and explain its different generations?
Ans: Garbage collector is a part of Common Language Runtime, which does automatic memory management for your application. When you create an object in your application, CLR allocates the memory for that object on Managed Heap.
Garbage collector gives number of benefits like -
Automatic Memory Management - You can build your application without thinking about how to free the memory as Garbage Collector gets called automatically by CLR.
Garbage Collector does proficient memory management for your objects.
Garbage Collector does automatic reclaim of the memory for those objects which are not in use and which are marked for deletion.
Garbage collector allocates the memory for objects in such a way that one object will not be able to use other object data accidently.
Q48. Explain the difference between managed and unmanaged code.
Ans: Managed code is a code created by the .NET compiler. It does not depend on the architecture of the target machine because it is executed by the CLR (Common Language Runtime), and not by the operating system itself. CLR and managed code offers developers few benefits, like garbage collection, type checking and exceptions handling.
On the other hand, unmanaged code is directly compiled to native machine code and depends on the architecture of the target machine. It is executed directly by the operating system. In the unmanaged code, the developer has to make sure he is dealing with memory usage and allocation (especially because of memory leaks), type safety and exceptions manually.
In .NET, Visual Basic and C# compiler creates managed code. To get unmanaged code, the application has to be written in C or C++.
Q49. Explain what LINQ is.
Ans: LINQ is an acronym for Language Integrated Query, and was introduced with Visual Studio 2008. LINQ is a set of features that extends query capabilities to the .NET language syntax by adding sets of new standard query operators that allow data manipulation, regardless of the data source. Supported data sources are: .NET Framework collections, SQL Server databases, ADO.NET Datasets, XML documents, and any collection of objects that support
IEnumerable or the generic
IEnumerable<T> interface, in both C# and Visual Basic. In short, LINQ bridges the gap between the world of objects and the world of data.
Q50. What do the following acronyms in .NET stand for: IL, CIL, MSIL, CLI and JIT?
Ans: IL, or Intermediate Language, is a CPU independent partially compiled code. IL code will be compiled to native machine code using current environmental properties by Just-In-Time compiler (JIT). JIT compiler translates the IL code to an assembly code and uses the CPU architecture of the target machine to execute a .NET application. In .NET, IL is called Common Intermediate Language (CIL), and in the early .NET days it was called Microsoft Intermediate Language (MSIL).
CLI, or Common Language Infrastructure, is an open specification developed by Microsoft. It is a compiled code library used for deployment, versioning, and security. In .NET there are two CLI types: process assemblies (EXE) and library assemblies (DLL). CLI assemblies contain code in CIL, and as mentioned, during compilation of CLI programming languages, the source code is translated into CIL code rather than into platform or processor specific object code.
- When compiled, source code is first translated to IL (in .NET, that is CIL, and previously called MSIL).
- CIL is then assembled into a bytecode and a CLI assembly is created.
- Before code execution, CLI code is passed through the runtime’s JIT compiler to generate native machine code.
- The computer’s processor executes the native machine code.
Q51. How many languages are supported by .NET at present time?
Ans: When .NET was introduced first time, it supports many languages like VB.NET,C#,COBOL, and Perl etc. At present time it supports almost 44 languages.
Related Interview Questions...