Monday, March 18, 2019

Dotnet interview questions


Compare C# and VB.NET
A detailed comparison can be found over here.
What is a base class and derived class?
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.
What is an extender class?
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.
A demonstration of extender classes can be found over here.
What is inheritance?
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
What is implementation and interface inheritance?
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.
What is inheritance hierarchy?
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.
How do you prevent a class from being inherited?
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.
When should you use inheritance?
Read this.
Explain Different Types of Constructors in C#?
There are four different types of constructors you can write in a class -
1. Default Constructor
2. Parameterized Constructor
3. Copy Constructor
4. Static Constructor

Define Overriding?
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.
Can you use multiple inheritance in .NET?
.NET supports only single inheritance. However the purpose is accomplished using multiple interfaces.
Why don’t we have multiple inheritance in .NET?
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.
What is an Interface?
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.
What are events and delegates?
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.
What is business logic?
It is the functionality which handles the exchange of information between database and a user interface.
What is a component?
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.
What is a control?
A control is a component that provides user-interface (UI) capabilities.
What are design patterns?
Design patterns are common solutions to common design problems.
What is a connection pool?
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.
What is a flat file?
A flat file is the name given to text, which can be read or written only sequentially.
What are functional and non-functional requirements?
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.
E.g.
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.
What is an Assembly? Explain different types of Assemblies?
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.
•    Manifest.
•    Type Metadata.
•    Intermediate Language.
•    Resources.
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.
What is the global assembly cache (GAC)?
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).
What is a stack? What is a heap? 
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.

What is instrumentation?
It is the ability to monitor an application so that information about the application’s progress, performance and status can be captured and reported.
What is code review?
The process of  examining the source code generally through a peer, to verify it against best practices.
What is logging?
Logging is the process of persisting information about the status of an application.
What are mock-ups?
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.
What is a Form?
A form is a representation of any window displayed in your application. Form can be used to create standard, borderless, floating, modal windows.
What is a multiple-document interface(MDI)?
A user interface container that enables a user to work with more than one document at a time. E.g. Microsoft Excel.
What is a single-document interface (SDI) ?
A user interface that is created to manage graphical user interfaces and controls into single windows. E.g. Microsoft Word
What is BLOB ?
A BLOB (binary large object) is a large item such as an image or an exe  represented in binary form.
What is ClickOnce?
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.
What is object role modeling (ORM) ?
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.
What is a private assembly?
A private assembly is local to the installation directory of an application and is used only by that application.
What is a shared assembly?
A shared assembly is kept in the global assembly cache (GAC) and can be used by one or more applications on a machine.
What is the difference between user and custom controls?
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.
Where do custom controls reside?
In the global assembly cache (GAC).
What is a third-party control ?
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).
What is a binary formatter?
Binary formatter is used to serialize and deserialize an object in binary format.
What is Boxing/Unboxing?
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.
What is a COM Callable Wrapper (CCW)?
CCW is a wrapper created by the common language runtime(CLR) that enables COM components to access .NET objects.
What is a Runtime Callable Wrapper (RCW)?
RCW is a wrapper created by the common language runtime(CLR) to enable .NET components to call COM components.
What is a digital signature?
A digital signature is an electronic signature used to verify/gurantee the identity of the individual who is sending the message.
What is garbage collection and explain its different generations?
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.

 
The Managed Heap is a memory area where a series of managed objects are stored and managed. As shown in the above diagram, the managed heap gets divided into three different sections which are known as Generations.
Generation 0 - This is the first generation under managed heap which is used to store and manage short-lived objects. All small size objects usually get allocated on Generation 0. When garbage collector reclaims the memory, it always reclaims the memory from generation 0 by default. The objects which are survived in Generation 0 will be pushed towards the generation 1.
Generation 1 - This generation again contain the short-lived objects and the objects which are survived from Generation 0. The objects which are survived in Generation 1 will be pushed towards the generation 2.
Generation 2 - This generation contains the long lived objects which are survived from multiple generations and are used till the process is running.
Garbage Collector first looks for the free memory in generation 0 which can be used to allocate the memory for the new object. The objects are always created in contagious memory. If the garbage collector finds sufficient memory for the new object, it does not search for the dead object and hence memory allocation process is always faster. But in case, sufficient memory is not available; then garbage collector reclaims the memory of the objects which are dead or not getting used for a long time.
When Garbage collector gets executed, it first of all, finds all the live objects. After this garbage collector updates the addresses of objects which will be compacted. Then it reclaims the memory of all the dead objects. Once the memory is reclaimed, it moves the lived objects to the next Generation. For example, the objects which live through in Generation 0 will be moved towards Generation 1. The objects which survived in generation 1 will be moved towards Generation 2. The objects which survived in Generation 2 will stay in Generation 2 only.
What is Application Domain and how does it work?
Windows Operating Systems load a set of resources like .EXE, DLLs and allocate the memory for those resources in an area called as Process. Windows OS creates a separate and isolated area for each running application. Making separate isolation area for each application, makes the process more secure and stable. In case, one process fails, it does not affect the other process.
.NET applications, however, are not hosted like traditional applications by Windows Operating System. Under .NET, .EXEs are hosted under a process by logical partitioning which is known as "Application Domain". Now you can host multiple application domains under one single process.

 
Application Domains consume less memory and power for processing the applications compared to the traditional processes for each application. In case one application domain fails, the other application domain will work as-is without any effects. You can also stop one application domain without affecting another application domain or without stopping an entire process.
One Application Domain cannot share/access the data from other Application Domain which is running within the same Domain or other Domain.
What is globalization?
Globalization is the process of customizing applications that support multiple cultures and regions.
What is localization?
Localization is the process of customizing applications that support a given culture and regions.
What is MIME?
The definition of MIME or Multipurpose Internet Mail Extensions as stated in MSDN is “MIME is a standard that can be used to include content of various types in a single message. MIME extends the Simple Mail Transfer Protocol (SMTP) format of mail messages to include multiple content, both textual and non-textual. Parts of the message may be images, audio, or text in different character sets.


No comments:

Post a Comment

Which Python course is best for beginners?

Level Up Your Python Prowess: Newbie Ninjas: Don't fret, little grasshoppers! Courses like "Learn Python 3" on Codecade...