Skip to main content

Top 20 Dot Net Interview Questions



  


   1.  Explain the difference between a class and an object.
In short, a class is the definition of an object, and an object is instance of a class. We can look at the class as a template of the object: it describes all the properties, methods, states and behaviors that the implementing object will have. As mentioned, an object is an instance of a class, and a class does not become an object until it is instantiated. There can be more instances of objects based on the one class, each with different properties.




2.   Explain the difference between managed and unmanaged code.
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++.



Managed code
Unmanaged code
Managed code is managed by CLR
Any code that is not managed by CLR
.NET framework is necessary to execute managed code
Independent of .NET framework
CLR manages memory management through garbage collection
Own runtime environment for compilation and execution

   3.  Explain the difference between boxing and unboxing. Provide an example.
Boxing is the process of converting a value type to the type object, and unboxing is extracting the value type from the object. While the boxing is implicit, unboxing is explicit.
 Example (written in C#):
 ~~~ int i = 13; object myObject = i; // boxing i = (int)myObject; // unboxing ~~~




   4.  Explain what LINQ is.
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` interface, in both C# and Visual Basic. In short, LINQ bridges the gap between the world of objects and the world of data.



  5.  Explain the difference between the Stack and the Heap.
             The short answer would be: in the Stack are stored value types (types inherited from `System.ValueType`), and in the Heap are stored reference types (types inherited from `System.Object`). We can say the Stack is responsible for keeping track of what is actually executing and where each executing thread is (each thread has its own Stack). The Heap, on the other hand, is responsible for keeping track of the data, or more precise objects.






  6.  Explain the differences between an Interface and an Abstract Class in .NET.
               An **interface** merely declares a contract or a behavior that implementing classes should have. It may declare only properties, methods, and events with no access modifiers. All the declared members must be implemented. An **abstract class** provides a partial implementation for a functionality and some abstract/virtual members that must be implemented by the inheriting entities. It can declare fields too. Neither interfaces nor abstract classes can be instantiated.


7. What are the different validators in ASP.NET?
1.    Required field Validator
2.   Range Validator
3.   Compare Validator
4.   Custom Validator
5.   Regular expression Validator
6.   Summary Validator





8. From which base class all Web Forms are inherited?
Page class.



9. What is ViewState?
ViewState is used to retain the state of server-side objects between page post backs.



10. What are the different types of caching?
ASP.NET has 3 kinds of caching :
1.    Output Caching,
2.   Fragment Caching,
3.   Data Caching.



11. List the events in page life cycle.
1) Page_PreInit
2) Page_Init
3) Page_InitComplete
4) Page_PreLoad
5) Page_Load
6) Page_LoadComplete
7) Page_PreRender
8) Render 




12. Write code to send e-mail from an ASP.NET application?
MailMessage mailMess = new MailMessage ();
mailMess.From = "abc@gmail.com
          ";
mailMess.To = "xyz@gmail.com";
mailMess.Subject = "Test email";
mailMess.Body = "Hi This is a test mail.";
SmtpMail.SmtpServer = "localhost";
SmtpMail.Send (mailMess);


13.           What are Generics in C# ?
     Generic is a class which allows the user to define classes and methods with the placeholder. Generics were added to version 2.0 of the C# language.
 The basic idea behind using Generic is to allow type (Integer, String, … etc and user-defined types) to be a parameter to methods, classes, and interfaces
  Generics help to separate logic and data type to increase reusability. In other words you can create a class whose data type can be defined on run time.


14. What is type safe in C#?
     C# language is a type safe language. ... NET helps write safe code. Type safety in . NET has been introduced to prevent the objects of one type from peeking into the memory assigned for the other object. Writing safe code also means to prevent data loss during conversion of one type to another.



15.  What is the difference between custom and user control?
           Custom Control
            User Control
Derives from control
Derives from UserControl
Dynamic Layout
Static Layout
Defines a single control
Defines a set of con
It has full toolbox support
Cannot be added to the toolbox
Loosely coupled control
Tightly coupled control




16.  Explain MVC.
MVC stands for model view controller which is an architecture to build .NET applications.
Model: They are the logical part of any application that handles the object storage and retrieval from the databases for an application.
ViewView handles the UI part of an application. They get the information from the models for their display.
ControllerThey handle the user interactions, figure out the responses for the user input and also render the view that is required for the user interaction.




17. What is the difference between overloading and overriding?
Overloading occurs when two or more methods in one class have the same method name but different parameters.

 Overriding allows a child class to provide a specific implementation of a method that is already provided its parent class


18. Why method overriding is used?
In object-oriented programming, the feature of overriding is used to provide a class, subclass or a child class to use a method that is already used by parent class to have a specific implementation.


19. What is polymorphism and example?
The word polymorphism means having many forms.
Real life example of polymorphism: A person at the same time can have different characteristic. Like a man at the same time is a father, a husband, an employee. So the same person possess different behavior in different situations. This is called polymorphism.





20. What is OOPs concept with example?
Object-Oriented Programming is a paradigm that provides many concepts, such as inheritance, data binding, polymorphism, etc.
The main aim of object-oriented programming is to implement real-world entities,
 for example, object, classes, abstraction, inheritance, polymorphism, etc.



Comments

Post a Comment

Popular posts from this blog

CyberArk Top 20 Interview Questions and Answers.

Q1- What is CyberArk? Ans: -  CyberArk is a PIM (Privilege Identity Management)/PAM(Privilege Access Management) security tool. It has PAS (Privilege Account security) solution, a full life cycle solution for managing the most privilege accounts and SSH Keys in the enterprise. Founded in 1999 & founder, Chairman and CEO- Udi Mokady and Alon Cohen. Q2- Why CyberArk is required? Ans: - Every Organization have 2 or 3 times more Privilege accounts then the employees and users and every privilege account required security from cyber-attacks (Internal or External). So in order to secure our privilege ids/accounts we used CyberArk because CyberArk provide password security. Cyber Ark is on the TOP of PIM/PAM service provider as per Gartner reports. Q3- What are the components of CyberArk. Ans: - The CyberArk components that released with PAS (Privileged Account Security) solution are listed below with their abbreviation:- 1 Privileged Identity Manage...

Top 25 SQL Interview Questions and Answers for freshers

1. What is SQL? SQL stands for Structured Query Language, and it is used to communicate with the Database. This is a standard language used to perform tasks such as retrieval, updation, insertion and deletion of data from a database. Basically, it is a database language that is used for the creation and deletion of databases, and it can be used to fetch and modify the rows of a table and also for multiple other things. 2. What are the keys in SQL?        A Key is a data item that exclusively identifies a record SQL Server supports various types of keys, which are listed below: Candidate Key Primary Key Unique Key Alternate Key Composite Key Super Key Foreign Key primary key A primary key is a combination of fields which uniquely specify a row. This is a special kind of unique key, and it has implicit NOT NULL constraint. It means, Primary key values cannot be NULL.  unique key A Unique key constraint uniquely i...