TOP 100 .NET INTERVIEW QUESTIONS AND ANSWERS 🔴🔴🔴







This image has an empty alt attribute; its file name is dotnet.jpg
TOP 100 .NET INTERVIEW QUESTIONS AND ANSWERS



TOP 100 .NET INTERVIEW QUESTIONS AND ANSWERS




What is .NET (definition)?




.NET is essentially a framework for software development. It is similar in nature to any other software development framework (J2EE etc) in that it provides a set of runtime containers/capabilities, and a rich set of pre-built functionality in the form of class libraries and APIs.
The .NET Framework is an environment for building, deploying, and running Web Services and other applications. It consists of three main parts: the Common Language Runtime, the Framework classes, andASP.NET



How many languages .NET is supporting now?




When .NET was introduced it came with several languages. VB.NET, C#, COBOL and Perl, etc. The site DotNetLanguages.Net says 44 languages are supported.



How is .NET able to support multiple languages?




A language should comply with the Common Language Runtime standard to become a .NET language. In .NET, code is compiled to Microsoft Intermediate Language (MSIL for short). This is called as Managed Code. This Managed code is run in .NET environment. So after compilation to this IL the language is not a barrier. A code can call or use a function written in another language.



How do you validate the controls in an ASP .NET page?




Using special validation controls that are meant for this. We have Range Validator, Email Validator.



Can the validation be done in the server side? Or this can be done only in the Client side?




Client side is done by default. Server side validation is also possible. We can switch off the client side and server side can be done.



What are Attributes (definition)?




Attributes are declarative tags in code that insert additional metadata into an assembly. There exist two types of attributes in the .NET Framework: Predefined attributes such as AssemblyVersion, which already exist and are accessed through the Runtime Classes; and custom attributes, which you write yourself by extending the System.Attribute class.



What is Web.config (definition)?




In classic ASP all Web site related information was stored in the metadata of IIS. This had the disadvantage that remote Web developers couldn't easily make Web-site configuration changes. For example, if you want to add a custom 404 error page, a setting needs to be made through the IIS admin tool, and you're Web host will likely charge you a flat fee to do this for you. With ASP.NET, however, these settings are moved into an XML-formatted text file (Web.config) that resides in the Web site's root directory. Through Web.config you can specify settings like custom 404 error pages, authentication and authorization settings for the Web sitempilation options for the ASP.NET Web pages, if tracing should be enabled, etc.
The Web.config file is an XML-formatted file. At the root level is the tag. Inside this tag you can add a number of other tags, the most common and useful one being the system.web tag, where you will specify most of the Web site configuration parameters. However, to specify application-wide settings you use the tag.
For example, if we wanted to add a database connection string parameter we could have a Web.config file like so.



Explain what relationship is between a Process, Application Domain, and Application?




Each process is allocated its own block of available RAM space, no process can access another process‟ code or data. If the process crashes, it dies alone without taking the entire OS or a bunch of other applications down.
A process is an instance of a running application. An application is an executable on the hard drive or network. There can be numerous processes launched of the same application (5 copies of Word running), but 1 process can run just 1 application.



What is a formatter
(definition) ?




A formatter is an object that is responsible for encoding and serializing data into messages on one end, and deserializing and decoding messages into data on the other end.



What is Delegation
(definition) ?




A delegate acts like a strongly type function pointer. Delegates can invoke the methods that they reference without making explicit calls to those methods.
Delegate is an entity that is entrusted with the task of representation, assign or passing on information. In code sense, it means a Delegate is entrusted with a Method to report information back to it when a certain task (which the Method expects) is accomplished outside the Method's class.



Write a query to find the total number of rows in a table?




Select count(*) from t_employee;



Write a query to eliminate duplicate records in the results of a table?




Select distinct * from t_employee;



Write a query to insert a record into a table?




Insert into t_employee values ('empid35','Barack','Obama');



Write a query to delete a record from a table?




delete from t_employee where id='empid35';



Write a query to display a row using index?




For this, the indexed column of the table needs to be set as a parameter in the
where clause
select * from t_employee where id='43';



Write a query to fetch the highest record in a table, based on a record, say salary field in the t_salary table




Select max(salary) from t_salary;



Write a query to fetch the first 3 characters of the field designation from the table t_employee?




Select substr(designation,1,3) from t_employee; -- Note here that the substr function has been used.



Write a query to concatenate two fields, say Designation and Department belonging to a table t_employee?




Select Designation + „ „ + Department from t_employee;



What is the difference between UNION and UNION ALL in SQL?




UNION is an SQL keyword used to merge the results of two or more tables using a Select statement, containing the same fields, with removed duplicate values. UNIONALL does the same, however it persists duplicate values.



If there are 4 SQL Select statements joined using Union and Union All, how many times should a Union be used to remove duplicate rows?Explain the differences between Server-side and Client-side code?




Server side code will execute at server (where the website is hosted) end, & all the business logic will execute at server end where as client side code will execute at client side (usually written in javascript, vbscript, jscript) at browser end.



What type of code (server or client) is found in a Code-Behind class?




Server side code.



How to make sure that value is entered in an asp:Textbox control?




Use a RequiredFieldValidator control.



Which property of a validation control is used to associate it with a server control on that page?




ControlToValidate property



How would you implement inheritance using VB.NET & C#?




C# Derived Class : Baseclass
VB.NEt : Derived Class Inherits Baseclass



Which method is invoked on the DataAdapter control to load the generated dataset with data?




Fill() method.



How many ways can wemaintain the state of a page?




Client Side - Query string, hidden variables, viewstate, cookies



Server side - application , cache, context, session, database



What is the use of a multicast delegate?




Amulticast delegate may be used to call more than one method.



What is the use of Singleton pattern?




A Singleton pattern .is used to make sure that only one instance of a class exists.



What is encapsulation
(definition)?




Encapsulation is the OOPs concept of binding the attributes and behaviors in a class, hiding the implementation of the class and exposing the functionality.



What is a data type
(definition)? How many types of data types are there in .NET?




A data type is a data storage format that can contain a specific type or range of values. Whenever you declare variables, each variable must be assigned a specific data type. Some common data types include integers, floating point, characters, and strings. The following are the two types of data types available in .NET:
Value type - Refers to the data type that contains the data. In other words, the exact value or the data is directly stored in this data type. It means that when you assign a value type variable to another variable, then it copies the value rather than copying the reference of that variable. When you create a value type variable, a single space in memory is allocated to store the value (stack memory). Primitive data types, such as int, float, and char are examples of value type variables.
Reference type - Refers to a data type that can access data by reference. Reference is a value or an address that accesses a particular data by address, which is stored elsewhere in memory (heap memory). You can say that reference is the physical address of data, where the data is stored in memory or in the storage device. Some built-in reference types variables in .Net are string, array, and object.



Is String a Reference Type or Value Type in .NET?




String is a Reference Type object.



Can a single .NET DLL contain multiple classes?




Yes, a single .NET DLL may contain any number of classes within it.



What is a CompositeControl in .NET
(definition) ?




CompositeControl is an abstract class in .NET that is inherited by those web controls that contain child controls within them.



What are the new features in .NET 2.0?




Plenty of new controls, Generics, anonymous methods, partial classes, iterators, property visibility (separate visibility for get and set) and static classes.



What are Partial Classes in Asp.Net 2.0
(definition)?




In .NET 2.0, a class definition may be split into multiple physical files but partial classes do not make any difference to the compiler as during compile time, the compiler groups all the partial classes and treats them as a single class.



What is a IL?




(IL) Intermediate Language is also known as MSIL (Microsoft Intermediate Language) or CIL (Common Intermediate Language). All .NET source code is compiled to IL. This IL is then converted to machine code at the point where the software is installed, or at run-time by a Just-In-Time (JIT) compiler.



What is a CTS
(definition)?




CTS defines all of the basic types that can be used in the .NET Framework and the operations performed on those type.
All this time we have been talking about language interoperability, and .NET Class Framework. None of this is possible without all the language sharing the same data types. What this means is that an int should mean the same in VB, VC++, C# and all other .NET compliant languages. This is achieved through introduction of Common Type System (CTS).



What is "Common Language Specification" (CLS)
definition?




CLS is the collection of the rules and constraints that every language (that seeks to achieve .NET compatibility) must follow. It is a subsection of CTS and it specifies how it shares and extends one another libraries.



What is "Common Language Runtime" (CLR) definition?




CLR is .NET equivalent of Java Virtual Machine (JVM). It is the runtime that converts a MSIL code into the host machine language code, which is then executed appropriately. The CLR is the execution engine for .NET Framework applications. It provides a number of services, including:
Code management (loading and execution)
-Application memory isolation
Verification of type safety
Conversion of IL to native code.
-Access to metadata (enhanced type information)
Managing memory for managed objects
Enforcement of code access security
Exception handling, including cross-language exceptions
Interoperation between managed code, COM objects, and preexisting DLL's (unmanaged code and data)
-Automation of object layout
Support for developer services (profiling, debugging, and so on).






What is a Managed Code (definition)?




Managed code runs inside the environment of CLR i.e. .NET runtime. In short all IL are managed code. But if you are using some third party software example VB6 or VC++ component they are unmanaged code as .NET runtime (CLR) does not have control over the source code execution of the language.



What is an assembly (definition)?




An assembly is a collection of one or more .exe or dll‟s. An assembly is the fundamental unit for application development and deployment in the .NET Framework. An assembly contains a collection of types and resources that are built to work together and form a logical unit of functionality. An assembly provides the CLR with the information it needs to be aware of type implementations.



What are the different types of Assembly?




There are two types of assembly Private and Public assembly. A private assembly is normally used by a single application, and is stored in the application's directory, or a sub-directory beneath. A shared assembly is normally stored in the global assembly cache, which is a repository of assemblies maintained by the .NET runtime. Shared assemblies are usually libraries of code which many applications will find useful, e.g. Crystal report classes which will be used by all application for Reports.



What is Difference between NameSpace and Assembly?




Following are the differences between namespace and assembly: Assembly is physical grouping of logical units. Namespace logically groups classes also Namespace can span multiple assembly.



What is Manifest (definition)?




Assembly metadata is stored in Manifest. Manifest contains all the metadata needed to do the following things:



  • Version of assembly
  • Security identity
  • Scope of the assembly
  • Resolve references to resources and classes.
  • The assembly manifest can be stored in either a PE file (an .exe or .dll) with Microsoft intermediate language (MSIL) code or in a stand-alone PE file that contains only assembly manifest information



What is garbage collection (definition)?




Garbage collection is a CLR feature which automatically manages memory. Programmers forget to release the objects while coding ….. Laziness (Remember in VB6 where one of the good practices is to set object to nothing). CLR automatically releases objects when they are no longer in use and refernced. CLR runs on non-deterministic to see the unused objects and cleans them. One side effect of this non-deterministic feature is that we cannot assume an object is destroyed when it goes out of the scope of a function. Therefore, we should not put code into a class destructor to release resources.



What is concept of Boxing and 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.



Overriding Definition




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.



What are events and delegates (definition)?




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 a connection pool (definition)?




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 code review (definition)?




The process of examining the source code generally through a peer, to verify it against best practices.



What is BLOB (definition)?




A BLOB (binary large object) is a large item such as an image or an exe represented in binary form.



What is a COM Callable Wrapper (CCW) definition?




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) definition?




RCW is a wrapper created by the common language runtime(CLR) to enable .NET components to call COM components.



What is MSIL (definition)?




When the code is compiled, the compiler translates your code into Microsoft intermediate language (MSIL). The common language runtime includes a JIT compiler for converting this MSIL then to native code.
MSIL contains metadata that is the key to cross language interoperability. Since this metadata is standardized across all .NET languages, a program written in one language can understand the metadata and execute code, written in a different language. MSIL includes instructions for loading, storing, initializing, and calling methods on objects, as well as instructions for arithmetic and logical operations, control flow, direct memory access, exception handling, and other operations.



What is JIT (definition)?




JIT is a compiler that converts MSIL to native code. The native code consists of hardware specific instructions that can be executed by the CPU.
Rather than converting the entire MSIL (in a portable executable[PE]file) to native code, the JIT converts the MSIL as it is needed during execution. This converted native code is stored so that it is accessible for subsequent calls.



What is GAC (definition)? What are the steps to create an assembly and add it to the GAC?




The global assembly cache (GAC) is a machine-wide code cache that stores assemblies specifically designated to be shared by several applications on the computer. You should share assemblies by installing them into the global assembly cache only when you need to.
Steps:



  • Create a strong name using sn.exe tool eg: sn -k mykey.snk



  • inAssemblyInfo.cs, add the strong name eg: [assembly:AssemblyKeyFile("mykey.snk")]



recompile project, and then install it to GAC in two ways :



  • drag & drop it to assembly folder (C:\WINDOWS\assembly OR C:\WINNT\assembly) (shfusion.dll tool)



  • gacutil -i abc.dll



What is the caspol.exe tool used for?




The caspol tool grants and modifies permissions to code groups at the user policy, machine policy, and enterprise policy levels.



What is Ilasm.exe used for?




Ilasm.exe is a tool that generates PE files from MSIL code. You can run the resulting executable to determine whether the MSILcode performs as expected.



What is Ildasm.exe used for?




Ildasm.exe is a tool that takes a PE file containing the MSIL code as a parameter and creates a text file that contains managed code.



What is the ResGen.exe tool used for?




ResGen.exe is a tool that is used to convert resource files in the form of .txt or .resx files to common language runtime binary .resources files that can be compiled into satellite assemblies.



What is a digital signature (definition)?




A digital signature is an electronic signature used to verify/guarantee the identity of the individual who is sending the message.



Name the classes that are introduced in the System.Numerics namespace.




The following two new classes are introduced in the System.Numerics namespace:
• BigInteger - Refers to a non-primitive integral type, which is used to hold a value of any size. It has no lower and upper limit, making it possible for you to perform arithmetic calculations with very large numbers, even with the numbers which cannot hold by double or long.
• Complex - Represents complex numbers and enables different arithmetic operations with complex numbers. A number represented in the form a + bi, where a is the real part, and b is the imaginary part, is a complex number.



Explain memory-mapped files.




Memory-mapped files (MMFs) allow you map the content of a file to the logical address of an application. These files enable the multiple processes running on the same machine to share data with each Other. The MemoryMappedFile.CreateFromFile() method is used to obtain a MemoryMappedFile object that represents a persisted memory-mapped file from a file on disk.
These files are included in the System.IO.MemoryMappedFiles namespace. This namespace contains four classes and three enumerations to help you access and secure your file mappings



Which method do you use to enforce garbage collection in .NET?




The System.GC.Collect() method.



State the differences between the Dispose() and Finalize().




CLR uses the Dispose and Finalize methods to perform garbage collection of run-time objects of .NET applications.
The Finalize method is called automatically by the runtime. CLR has a garbage collector (GC), which periodically checks for objects in heap that are no longer referenced by any object or program. It calls the Finalize method to free the memory used by such objects. The Dispose method is called by the programmer. Dispose is another method to release the memory used by an object. The Dispose method needs to be explicitly called in code to dereference an object from the heap. The Dispose method can be invoked only by the classes that implement the IDisposable interface.



What are tuples (definition)?




Tuple is a fixed-size collection that can have elements of either same or different data types. Similar to arrays, a user must have to specify the size of a tuple at the time of declaration. Tuples are allowed to hold up from 1 to 8 elements and if there are more than 8 elements, then the 8th element can be defined as another tuple. Tuples can be specified as parameter or return type of a method.



Which is the root namespace for fundamental types in .NET Framework?




System.Object is the root namespace for fundamental types in .NET Framework.



Define variable and constant.




A variable can be defined as a meaningful name that is given to a data storage location in the computer memory that contains a value. Every variable associated with a data type determines what type of value can be stored in the variable, for example an integer, such as 100, a decimal, such as 30.05, or a character, such as 'A'.
You can declare variables by using the following syntax;
A constant is similar to a variable except that the value, which you assign to a constant, cannot be changed, as in case of a variable. Constants must be initialized at the same time they are declared. You can declare constants by using the following syntax:
const int interestRate = 10;




Which statement is used to replace multiple if-else statements in code?




In Visual Basic, the Select-Case statement is used to replace multiple If - Else statements and in C#, the switchcase statement is used to replace multiple if-else statements.



What is an identifier
(definition) ?




Identifiers are northing but names given to various entities uniquely identified in a program. The name of identifiers must differ in spelling or casing. For example, MyProg and myProg are two different identifiers. Programming languages, such as C# and Visual Basic, strictly restrict the programmers from using any keyword as identifiers. Programmers cannot develop a class whose name is public, because, public is a keyword used to specify the accessibility of data in programs.



Can one DLL file contain the compiled code of more than one .NET language?




No, a DLL file can contain the compiled code of only one programming language.



What is Native Image Generator
(definition) ?




The Native Image Generator (Ngen.exe) is a tool that creates a native image from an assembly and stores that image to native image cache on the computer. Whenever, an assembly is run, this native image is automatically used to compile the original assembly. In this way, this tool improves the performance of the managed application by loading and executing an assembly faster.
Note that native images are files that consist of compiled processor-specific machine code. The Ngen.exe tool installs these files on to the local computer.



Name the MSIL Disassembler utility that parses any .NET Framework assembly and shows the information in human readable format




The Ildasm.exe utility.



What is the significance of the Strong Name tool?




The Strong Name utility (sn.exe) helps in creating unique public-private key pair files that are called strong name files and signing assemblies with them. It also allows key management, signature generation, and signature verification.



Discuss the concept of strong names.




Whenever, an assembly is deployed in GAC to make it shared, a strong name needs to be assigned to it for its unique identification. A strong name contains an assembly's complete identity - the assembly name, version number, and culture information of an assembly. A public key and a digital signature, generated over the assembly, are also contained in a strong name.Astrong name makes an assembly identical in GAC.



What is the difference between .EXE and .DLL files?




EXE
1.It is an executable file, which can be run independently.
2.EXE is an out-process component, which means that it runs in a separate process.
3.It cannot be reused in an application.
4.It has a main function.
DLL
1.It is Dynamic Link Library that is used as a part of EXE or other DLLs. It cannot be run independently.
2.It runs in the application process memory, so it is called as in-process component.
3.It can be reused in an application.
4.It does not have a main function.



Which utility allows you to reference an assembly in an application?




An assembly can be referenced by using the gacutil.exe utility with the /r option. The /r option requires a reference type, a reference ID, and a description.



The AssemblyInfo.cs file stores the assembly configuration information and other information, such as the assembly name, version, company name, and trademark information. (True/False).



What are code contracts
(definition) ?




Code contracts help you to express the code assumptions and statements stating the behavior of your code in a language-neutral way. The contracts are included in the form of pre-conditions, post-conditions and objectinvariants. The contracts help you to improve-testing by enabling run-time checking, static contract verification, and documentation generation.
The System.Diagnostics.Contracts namespace contains static classes that are used to express contracts in your code.



What are Merge Module projects
(definition) ?




Merge Module projects enable creation and deployment of code that can be shared by multiple applications. This may include Dll‟s, resource files, registry based entries etc. The Windows database also keeps track of a reference count for those projects.



What is a Serviced component
(definition) ?




A serviced component is a class that is inside all the CLS-complaint languages. It derives directly or indirectly from the System.EnterpriseServices.ServicedComponent class. This way of configuring the classes allows to be hosted in a COM+ application and is able to use COM+ services.



What is a flat file
(definition) ?




A flat file is the name given to text, which can be read or written only sequentially.



What is an XML Web service
(definition) ?




XML Web Service is a unit of code that can be accessed independent of platforms and systems. They are used to interchange data between different systems in different machines for interoperability using HTTP protocols. Requests are made and responses are returned in the form of XML as XML is language and platform independent.



Describe the steps to deploy a web service.





87
QUESTION
a. Using xcopy or Publish wizard copy the file to the destination server.
b. Make the destination directory a virtual directory in IIS.



What is MIME
(definition) ?




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. The MIME standard derives from RFCs such as 2821 and 2822”



What are mock-ups
(definition) ?




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 logging
(definition) ?




Logging is the process of persisting information about the status of an application.



What’s a Windows process in .NET
(definition) ?




Windows Process is an application that‟s running and had been allocated memory in .NET



How to manage pagination in a page?




Using pagination option in DataGrid control. We have to set the number of records for a page, then it takes care of pagination by itself.



What is smart navigation
(definition) ?




The cursor position is maintained when the page gets refreshed due to the server side validation and the page gets refreshed.



How do you trigger the Paint event in System.Drawing?




Invalidate the current form, the OS will take care of repainting. The Update method forces the repaint.



How do you assign RGB color to a System.Drawing.Color object?




Call the static method FromArgb of this class and pass it the RGB values in .NET



What’s a proxy of the server object in .NET Remoting?




It‟s a fake copy of the server object that resides on the client side and behaves as if it was the server. It handles the communication between real server object and the client object. This process is also known as the marshaling.



What are Channels in .NET Remoting?




Channels represent the objects that transfer the other serialized objects from one application domain to another and from one computer to another, as well as one process to another on the same box. A Channel must exist before an object can be transferred.



What’s singlecall activation mode used for in .NET?




If the server object is instantiated for responding to just one single request, the request should be made in SingleCall mode in .NET



What’s Singleton activation mode in .NET?




A Single object is instantiated of the number of clients accessing it. Lifetime of this object is determined by lifetime lease.



How do you define the lease of the object in .NET?




By Implementing Ilease interface when writing the class code in .NET



Can you configure a .NET Remoting object via XML file?




Yes, via machine.config and application level .config file (or web.config in ASP.NET). Application-level XML settings take precedence over machine.config.

No comments:

Post a Comment