Hi All,
I wanted to share interview questions asked at FTD Hyderabad Interview for Dot Net developer experienced candidate.
Please use the questions as reference and research the answers for self understanding
The questions are as follows
I wanted to share interview questions asked at FTD Hyderabad Interview for Dot Net developer experienced candidate.
Please use the questions as reference and research the answers for self understanding
The questions are as follows
1. Introduce
yourself
2. In which
topics are you comfortable
C# OOPS :
1. Tell me
about Hash table vs Dictionary
2.What are
dey and which is faster
Dictionary is faster as it is strongly
typed
3. What is the difference
4. Boxing
and unboxing
5. Array and
array list are having same number of elements or Size which is faster and why
it is fast
Array will be faster in this case when
compared to ArrayList as the implementation of the arrayList in the internal
side is an array. As ArrayList will allow different datatypes to save it
requires boxing and unboxing which makes it slow.
Along with that ArrayList
4.Using key
usage why ?
5 Memory
leakage
https://msdn.microsoft.com/en-us/library/ms998530.aspx
Run a
profiler on your code.
Here are two
good options:
RedGate's
memory profiler
Jetbrains
dotTrace
Memory leaks
in .NET are not that common, but when they happen it is most commonly due to
unattached event handlers. Make sure you detach handlers, before the listeners
go out of scope.
Another
option is if you forget to call Dispose() on IDisposable resources. This may
prevent cleanup of unmanaged resources (which are not handled by GC).
6. Is Webservice
method overloading possible ? and How it
can be achieved ?
The function
overloading in Web Service is not as straightforward as in class. While trying
to overload member function, we make two or more methods with the same name
with different parameters. But this will not work in web services and will show
runtime error because WSDL is not supported by the same method name
The
procedure to solve this problem is very easy. Start each method with a Web
Method attribute. Add Description property to add a description of web method
and MessageName property to change web method name.
[WebMethod(MessageName
= "<name>", Description = "<description>")]
Hide Copy Code
namespace
TestOverloadingWebService
{
[WebService(Namespace =
"http://tempuri.org/", Description=" <b> Function
overloading in Web Services
</b>")]
public class
OverloadingInWebService : System.Web.Services.WebService
{
[WebMethod(MessageName =
"AddInt", Description = "Add two integer
Value", EnableSession = true)]
public int Add(int a, int b)
{
return (a + b);
}
[WebMethod(MessageName =
"AddFloat", Description = "Add two Float
Value", EnableSession = true)]
public float Add(float a, float b)
{
return (a + b);
}
}
}
7. GAC What
is global assembly cache
Global
Assembly Cache
Each
computer where the common language runtime is installed has a machine-wide code
cache called the global assembly cache. The global assembly cache stores
assemblies specifically designated to be shared by several applications on the
computer.
Use a
developer tool called the Global Assembly Cache tool (Gacutil.exe), provided by
the Windows Software Development Kit (SDK).
Starting
with the .NET Framework 4, the default location for the global assembly cache
is %windir%\Microsoft.NET\assembly.
In earlier
versions of the .NET Framework, the default location is %windir%\assembly.
8. What is
presistent cookie
9. What are
cookies
10. What is
session management, how did you apply session management is your application
https://msdn.microsoft.com/en-us/library/z1hkazw7.aspx
Server side
session
4 types
Application state session
Session
state
Profile
properties
Database
support
Client side session
View state
Control state
Hidden fields
Cookies
Query strings
11. How can
session state is maintained in your application
12. What is
client side session and server side
13. What is
View bag and view data
Which is dynamic
viewBag.foo - dynamic
viewData["foo"]
14.
Similarities between ViewBag & ViewData , which is dynamic
Helps to
maintain data when you move from controller to view. Used to pass data from
controller to corresponding view. Short life means value becomes null when
redirection occurs. This is because their goal is to provide a way to
communicate between controllers and views. It’s a communication mechanism
within the server call.
Difference
between ViewBag & ViewData:
ViewData is
a dictionary of objects that is derived from ViewDataDictionary class and
accessible using strings as keys. ViewBag is a dynamic property that takes
advantage of the new dynamic features in C# 4.0. ViewData requires typecasting
for complex data type and check for null values to avoid error. ViewBag doesn’t
require typecasting for complex data type
ViewData:
It’s required type casting for complex data type and check for null values to
avoid error.
ViewBag: It
doesn’t require type casting for complex data type.
Consider the
following example:
public class
HomeController : Controller
{
public ActionResult Index()
{
var emp = new Employee
{
EmpID=101,
Name = "Deepak",
Salary = 35000,
Address = "Delhi"
};
ViewData["emp"] = emp;
ViewBag.Employee = emp;
return View();
}
}
And the code
for View is as follows:
@model
MyProject.Models.EmpModel;
@{
Layout =
"~/Views/Shared/_Layout.cshtml";
ViewBag.Title = "Welcome to Home
Page";
var viewDataEmployee =
ViewData["emp"] as Employee; //need type casting
}
<h2>Welcome
to Home Page</h2>
This Year
Best Employee is!
<h4>@ViewBag.emp.Name</h4>
<h3>@viewDataEmployee.Name
-------------------------------------------------------------------------
18. Can we
have catch without try and finally
19. Try and
finally without Catch
try need
either catch or finally for sure.
but not both
catch and finally are mandatory.
20. What is
deferred execution LINQ
LINQ query,
you always work with objects. The object may in-process object or out-process
object. Based on objects, LINQ query expression is translated and executed.
There are two ways of LINQ query execution
a . In case of differed execution,
a query is
not executed at the point of its declaration. It is executed when the Query
variable is iterated by using loop like as for, foreach.
DataContext
context = new DataContext();
var query =
from customer in context.Customers
where customer.City == "Delhi"
select customer; // Query does not execute
here
foreach (var Customer in query) // Query
executes here
{
Console.WriteLine(Customer.Name);
}
A LINQ query expression often causes deferred
execution. Deferred execution provides the facility of query reusability, since
it always fetches the updated data from the data source which exists at the
time of each execution.
b. Immediate
Execution
In case of
immediate execution, a query is executed at the point of its declaration. The
query which returns a singleton value (a single value or a set of values) like
Average, Sum, Count, List etc. caused Immediate Execution.
You can
force a query to execute immediately of by calling ToList, ToArray methods.
DataContext
context = new DataContext();
var query =
(from customer in context.Customers
where customer.City == "Delhi"
select customer).Count(); // Query execute
here
Immediate
execution doesn't provide the facility of query re-usability since it always
contains the same data which is fetched at the time of query declaration
22. What is
routing .and Uses
APP_sTART RouteConfig. RegisterRoutes in RouteConfig cls.
route =
{controller}/{action}/{id. optional}
WebApi.RouteConfig
api/{controller}/{action}/{id}
23. Can we
pass data from one controller to other controller
24. What are
'Action Filters'
Using an
Action Filter
An action
filter is an attribute. You can apply most action filters to either an
individual controller action or an entire controller.
An action
filter is an attribute that you can apply to a controller action -- or an
entire controller -- that modifies the way in which the action is executed. The
ASP.NET MVC framework includes several action filters:
OutputCache
– This action filter caches the output of a controller action for a specified
amount of time.
HandleError
– This action filter handles errors raised when a controller action executes.
Authorize –
This action filter enables you to restrict access to a particular user or role
For example,
the Data controller in Listing 1 exposes an action named Index() that returns
the current time. This action is decorated with the OutputCache action filter.
This filter causes the value returned by the action to be cached for 10
seconds.
Listing 1 –
Controllers\DataController.cs
using
System;
using
System.Web.Mvc;
namespace
MvcApplication1.Controllers
{
public class DataController : Controller
{
[OutputCache(Duration=10)]
public string Index()
{
return
DateTime.Now.ToString("T");
}
}
}