Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
2. What is a singleton?
A singleton is a design pattern used when only one instance of an object is created and shared; that is, it
only allows one instance of itself to be created. Any attempt to create another instance simply returns a
reference to the first one. Singleton classes are created by defining all class constructors as private. In
addition, a private static member is created as the same type of the class, along with a public static
member that returns an instance of the class.
“Finally” block will be executed irrespective of exception. So while executing the code in try block when
exception is occurred, control is returned to catch block and at last “finally” block will be executed. So
closing connection to database / releasing the file handlers can be kept in “finally” block.
4. What is boxing?
Boxing is the process of explicitly converting a value type into a corresponding reference type. Basically,
this involves creating a new object on the heap and placing the value there. Reversing the process is just
as easy with unboxing, which converts the value in an object reference on the heap into a corresponding
value type on the stack. The unboxing process begins by verifying that the recipient value type is
equivalent to the boxed type. If the operation is permitted, the value is copied to the stack
This is a situation where in, multiple resources are dependent on each other and this causes a lock
condition and this makes the resource to be unused.
9. What are implementation inheritance and interface inheritance?
Implementation inheritance is achieved when a class is derived from another class in such a way that it
inherits all its members. Interface inheritance is when a class inherits only the signatures of the
functions from another class.
Answer: constructor chaining is a way to connect two or more classes in a relationship as Inheritance, in
Constructor Chaining every child class constructor is mapped to parent class Constructor implicitly by
base keyword so when you create an instance of child class to it’ll call parent’s class Constructor without
it inheritance is not possible.
Controller receives the end user request,performs operations on the model as required and renders the
view.
5. What is ActionResult?
ActionResult is a class which represents the result of an action method.Action methods returns an
object of a type which derives from this ActionResult class.Since ActionResult is an abstract class so it
provides few derived classes whose object the action method can create to return the
response.Also there are few methods available to the controller class to create ActionResult subclass,so
we don’t need to explicitly create an object of the ActionResult and can just call the method.
Some of the classes deriving from the ActionResult are:
Authorization filter
Action filter
Result filter
Exception filter
Inline expressions can be mixed with normal html and are not required to start with @.
14. Mention what is the difference between Temp data, View, and View Bag?
Temp data: It helps to maintain data when you shift from one controller to other controller.
View data: It helps to maintain data when you move from controller to view.
These are some of the most important MVC interview questions and answers which you should know
when attending MVC interview.These questions will not only help you with the interview but would also
help understand MVC better.