Latest 38 Dot Net Interview Questions For Freshers
1. Explain the AdRotator Control?
Answer: AdRotator control is used to create dynamic ads. The AdRotator Control presents ad images each time a user enters or refreshes a webpage. When the ads are clicked, it will navigate to a new Web location. The AdRotator control is used to display a sequence of ad images. The AdRotator control to work we need an Advertisement file (XML file) and some sample images.
Adding the AdRotator web server control to your web application. first, select the AdRotator and drag and drop the control to your web form. Map the XML file which contains the details about each and every ad.
The advertisement file is an XML file. The following are some of the elements of this XML file.
: Optional. The path to the image file.
: Optional. The URL to link to if the user clicks the ad.
: Optional. An alternate text for the image.
: Optional. The display rates in percent of the hits.
2. Explain namespaces in C#?
Answer: Namespaces are containers for the classes. We will use namespaces for grouping the related classes in C#. “Using” keyword can be used for using the namespace in another namespace.
3. What is the difference between “constant” and “readonly” variables in C#?
Answer: “Const” keyword is used for making an entity constant. We cannot modify the value later in the code. Value assigning is mandatory to constant variables.
“readonly” variable value can be changed during runtime and value to readonly variables can be assigned in the constructor or at the time of declaration.
4. Which base class does the web form inherit from?
Answer:
Page class in the System.Web.UI namespace.
5. Which are the new special folders that are introduced in ASP.NET 2.0?
Answer:
There are seven new folders introduced in ASP.NET 2.0:
a\App_Browsers folder – Holds browser definitions(.brower) files which identify the browser and their capabilities.
\App_Code folder – Contains source code (.cs, .vb) files which are automatically compiled when placed in this folder. Additionally placing web service files generates a proxy class(out of .wsdl) and a typed dataset (out of .xsd).
\App_Data folder – Contains data store files like .mdf (Sql Express files), .mdb, XML files etc. This folder also stores the local DB to maintain membership and role information.
\App_GlobalResources folder – Contains assembly resource files (.resx) which when placed in this folder are compiled automatically. In earlier versions, we were required to manually use the resgen.exe tool to compile resource files. These files can be accessed globally in the application.
\App_LocalResources folder – Contains assembly resource files (.resx) which can be used by a specific page or control.
\App_Themes folder – This folder contains .css and .skin files that define the appearance of web pages and controls.
\App_WebReferences folder – Replaces the previously used Web References folder. This folder contains the .disco, .wsdl, .xsd files that get generated when accessing remote web services.
6. Explain CLR, CTS, CLS under .NET Framework?
Answer: Common Language Runtime is one of the main building blocks of Microsoft .NET Framework which is responsible for performing various operations under .NET Framework.
dotnet-compilation
When you design the application using Microsoft .NET languages like C#.NET or VB.NET, the language has its own compiler 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. (.net Training Online)
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. The Common Type System for language integration works as follows –
dotnet-fw-cts
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 the .NET framework are CLS complaint.
7. Explain sealed class in C#?
Answer: A sealed class is used to prevent the class from being inherited from other classes. So “sealed” modifier also can be used with methods to avoid the methods to override in the child classes.
8. List out the differences between Array and ArrayList in C#?
Answer: Array stores the values or elements of the same data type but ArrayList stores values of different data types.
Arrays will use the fixed length but ArrayList does not use fixed-length like an array.
9. What is Microsoft Intermediate Language (MSIL)?
Answer: The .NET Framework is shipped with compilers of all .NET programming languages to develop programs. There are separate compilers for the Visual Basic, C#, and Visual C++ programming languages in .NET Framework. Each .NET compiler produces an intermediate code after compiling the source code. The intermediate code is common for all languages and is understandable only to a .NET environment. This intermediate code is known as MSIL. (.net Training Online)
10. What is the meaning of object pooling?
Answer: Object pooling is a concept of storing a pool (group) of objects in memory that can be reused later as needed. Whenever a new object is required to create, an object from the pool can be allocated for this request; thereby, minimizing the object creation. A pool can also refer to a group of connections and threads. Pooling, therefore, helps in minimizing the use of system resources, improves system scalability, and performance.
11. What are the pre-requisites for connection pooling?
Answer: There must be multiple processes to share the same connection describing the same parameters and security settings. The connection string must be identical.
12. What is the function of the ViewState property?
Answer: The ASP.NET 4.0 introduced a new property called ViewStateMode for the Control class. Now you can enable the view state to an individual control even if the view state for an ASP.NET page is disabled.
13. What is the basic difference between ASP and ASP.NET?
Answer: The basic difference between ASP and ASP.NET is that ASP is interpreted; whereas, ASP.NET is compiled. This implies that since ASP uses VBScript; therefore when an ASP page is executed, it is interpreted. On the other hand, ASP.NET uses .NET languages, such as C# and VB.NET, which are compiled to Microsoft Intermediate Language (MSIL).
14. In which event are the controls fully loaded?
Answer: Page load event guarantees that all controls are fully loaded. Controls are also accessed in Page_Init events but you will see that view state is not fully loaded during this event. (Interview Questions and Answers)
15. How can we identify that the Page is Post Back?
Answer: Page object has an “IsPostBack” property, which can be checked to know that is the page posted back.
16. What are the advantages of the code-behind feature?
Answer:
i)Makes code easy to understand and debug by separating application logic from HTML tags
ii)Provides the isolation of effort between graphic designers and software engineers
iii)Removes the problems of browser incompatibility by providing code files to exist on the Web server and supporting Web pages to be compiled on demand.
17. Differentiate globalization and localization?
Answer: The globalization is a technique to identify the specific part of a Web application that is different for different languages and make separate that portion from the core of the Web application. The localization is a procedure of configuring a Web application to be supported for a specific language or locale.
18. What is Serialization in .NET?
Answer: The serialization is the process of converting the objects into a stream of bytes.
they or used for transport the objects(via remoting) and persist objects(via files and databases)
19. Difference between Class And Interface in .NET?
Answer: Class is a logical representation of an object. It is a collection of data and related sub procedures with a definition.
The interface is also a class containing methods which are not having any definitions.
Class does not support multiple inheritances. But interface can support
20. Can any object be stored in a Viewstate in .NET?
Answer: An object that either is serializable or has a TypeConverter defined for it can be persisted in ViewState.
21. Why .NET Framework?
Answer: .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.
Before exploring the .NET Framework, we first have to understand the issues/pain areas which developers have faced in other technologies –
Programming with Win32 API – Earlier we were using Win32 API and C language. This paradigm does not offer Object-Oriented Features as C is a structured language. There is no better way of memory management either as it is done manually. Using Pointers is a big pain area for developers.
Programming with VC++ – Many of us use C++ and MFS as a programming language which offers the features of Object-Oriented Features. However, C++ is built on top of C language and hence the development can still cumbersome for many novice programmers who are dealing with memory management and pointers.
Programming with Visual Basic 6.0 – Way back in 1998, VB 6.0 as a development language had made development efforts easier. For example designing complex UI, Data-Centric applications and much more. But VB 6.0 is not an object-oriented language and is outdated now. When designing Multi-threaded application, we still have to go back to Win32 APIs.
Programming with COM – Component Object Model is a specification which is used for developing reusable components which can be called across the languages like VC++, Delphi. But with COM we also get “DLL Hell”. DLL Hell is the issue of maintaining multiple versions of a component for multiple applications.
Under the .NET Framework, many of these problems have been addressed and resolved.
Microsoft .NET Framework provides a huge no. of benefits compared with the legacy languages –
No more COM Specifications in .NET. So, we automatically get away from DLL Hell.
Microsoft .NET supports language integration.
Microsoft .NET Base Class Library offers a wrapper over many raw API calls which can be used in various .NET languages.
You can call COM components in .NET and .NET Components in COM using interoperability.
A Common Runtime Engine shared by all the .NET Languages.
A single framework to develop Windows/Web applications.
We have no. of languages which make developers adapt the .NET Framework for application development.
22. What is BCL?
Answer: 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 live 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.
23. What is the concept of DISPOSE method?
Answer: DISPOSE method belongs to the IDisposable interface. It is used to free unmanaged resources like files, network connection, etc. It manages and handles this by an instance of the class that implements this interface. Dispose of methods must be called explicitly and hence any object using IDisposable must also implement finalizer to free resources in situations wherein Dispose is not called. Multiple calls to dispose of the method must be ignored when called once. The objects disposable methods must be called in the order of containment.
24. What is CLR?
Answer: The Common Language Runtime (CLR) is a core component of the .NET framework. It is Microsoft’s implementation of the Common Language Infrastructure (CLI) standard, which defines an execution environment for program code. In the CLR, code is expressed in a form of bytecode called the Common Intermediate Language (CIL). Developers using the CLR write code in a language such as C# or VB.NET. At compile time, the .NET compiler converts such code into CIL code. At runtime, the CLR’s just-in-time compiler converts the CIL code into code native to the operating system. Alternatively, the CIL code can be compiled to native code in a separate step prior to runtime by using the Native Image Generator (NGEN). This speeds up all later runs of the software as the CIL-to-native compilation is no longer necessary.
During the execution of the program, the Common Language Runtime (CLR) manages memory, thread execution, Garbage Collection (GC), Exception Handling, Common Type System (CTS), code safety verifications, and other system services. The Common Language Runtime (CLR) environment is also referred to as a managed environment because during the execution of a program it also controls the interaction with the Operating System.
25. What is a NameSpace?
Answer: A namespace is a group of classes, structures, interfaces, enumerations, and delegates, organized in a logical hierarchy by function, that enable you to access the core functionality you need in your applications.
Namespaces are the way that .NET avoids name clashes between classes. A Namespace is no more than a grouping of data types, but it has the effect that the names of all data types within a namespace automatically get prefixed with the name of the namespace. It is also possible to nest namespaces within each other.
26. What is Delegation in .NET?
Answer: 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.
27. Whats an assembly?
Answer: Assemblies are the building blocks of .NET Framework applications; they form the fundamental unit of deployment, version control, reuse, activation scoping, and security permissions. An assembly is a collection of types and resources that are built to work together and form a logical unit of functionality. An assembly provides the common language runtime with the information it needs to be aware of type implementations. To the runtime, a type does not exist outside the context of an assembly. (C# .Net Training Videos)
28. How do you create a permanent cookie?
Answer: Setting the Expires property to MinValue means that the Cookie never expires.
29. What’s a Windows process in .NET?
Answer:
Windows process is an application that’s running and had been allocated memory in.NET
30. Differences between dataset.clone and dataset.copy?
Answer: Clone – Copies the structure of the DataSet, including all DataTable schemas, relations, and constraints. Does not copy any data.
Copy – Copies both the structure and data for this DataSet.
31. What do you mean by authentication and authorization?
Answer: Authentication is the process of validating a user on the credentials(username and password) and authorization performs after authentication. After Authentication a user will be verified for performing the various tasks, It access is limited it is known as authorization.
32. Where do you add an event handler?
Answer:
It’s the Attributesproperty, the Add function inside that property. e.g.btnSubmit.Attributes.Add(“onMouseOver”,”someClientCode();”)
33. Differentiate between client-side and server-side validations in Web pages?
Answer: Client-side validations take place at the client end with the help of JavaScript and VBScript before the Web page is sent to the server. On the other hand, server-side validations take place at the server end.
34. What is ViewState?
Answer: The ViewState is a feature used by ASP.NET Web page to store the value of a page and its controls just before posting the page. Once the page is posted, the first task by the page processing is to restore the ViewState to get the values of the controls.
35. What does the Orientation property do in a Menu control?
Answer: Orientation property of the Menu control sets the horizontal or vertical display of a menu on a Web page. By default, the orientation is vertical.
36. What is AutoPostBack?
Answer: If you want a control to postback automatically when an event is raised, you need to set the AutoPostBack property of the control to True.
37. What are different types of authentication techniques that are used in connection strings to connect .NET applications with Microsoft SQL Server?
Answer:
The Windows Authentication option
The SQL Server Authentication option
38. Give an example of using a sealed class in C#?Answer:
Below is the sample code of sealed class in C# –
class X {}
sealed class Y : X {}
Sealed methods –
class A
protected virtual void First() { }
protected virtual void Second() { }
class B: A
sealed protected override void First() {}
protected override void Second() { }
If any class inherits from class “B” then method – “First” will not be overridable as this method is sealed in class B.