Questions and Answers of SharePoint Interview for Developers - Part 1

Q. What Do you know about SharePoint Object

Ans. In Sharepoint Object model there are
two Important namespaces.

The Microsoft.Office.Server
namespace is the root namespace of all Office Server objects and Microsoft.SharePoint
is the root namespace for all WSS objects.
Read More at SharePoint 2007 Object Model

Q. Can you
develop webparts and other SharePoint solutions at your local

In order to run and debug sharePoint solutions, the
project must reside on the server which has Windows sharePoint services
installed. However, you can reference the Microsoft.SharePoint dll in
your project at your local, but you won't be able to run it.

Q. How do you debug SharePoint

To debug SharePoint webpart (or any solution) you
can simply drag and drop your complied .dll in GAC and recycle the app pool. You
can also run upgrade solution command from stsadm.

Q. How would you retrieve large number of Items form
the list ?

Ans. To retrieve
large number of items with a better performance we can either use SPQuery or
PortalSiteMapProvider Class. Read More with Examples
Retrieving large number of Items from sharepoint 2007 list

Q. How Do you implement Impersonation in ShrePoint.

Ans. By Using RunWithElevatedPrivileges method provided by
SPSecurity class.
See e.g Impersonation in Sharepoint

Q: What is the
performance impact of

RunWithElevatedPrivileges creates a new thread with the App Pool's credentials,
blocking your current thread until it finishes.

Q. How will you add Code behind to a Custom
Applictaion Page or a Layout Page in SharePoint?

You do not
deploy a code behind file with your custom Layouts page. Instead, you can have
the page inherit from the complied dll of the solution to access the code

Q. What is the difference between a Site Definition
and a Site Template?

Ans. Site Definitions are
stored on the hard drive of the SharePoint front end servers. They are used by
the SharePoint application to generate the sites users can create. Site
Templates are created by users as a copy of a site they have configured and
modified so that they do not have to recreate lists, libraries, views and
columns every time they need a new instance of a site.

Q. Why do you use Feature Receivers

Feature Receivers are used to execute any code on
Activation\Deactivation of a Feature. You can use it for various

Q. Can you give a example
where feature receivers are used.

. You can use it to assign an
event receiver feature to a specific type of list or can write a code in a
feature receivers Deactivate method to remove a webpart from webpart

Q. Where do you deploy the additional files used in
your webpart, like css or javascript files, and how do you use them in your

Ans. You can deploy the css or
javascript files in _layouts folder in SharePoint's 12 hive. To use them in your
webpart, you need to first register them to your webpart page and then specify a
virtual path for the file for e.g. _layouts\MyCSS.css See Code examples at Using External Javascript, CSS or Image File in a WebPart.

When should you dispose SPWeb and SPSite objects?

Ans. According to the best Practices you
should always dispose them if you have created them in your code. You can
dispose them in Finally block or you can use the "Using" clause, so that they
gets disposed when not required. If you are using SPContext then you need not
dispose the spsite or spweb objects.

Q. What are the best practices for SharePoint

Some of the best practices are:

1. You
should always dispose SPsite and SPWeb objects, once you refer them in your
code. Using the "Using" clause is recommended.

2. Use
RunwithelevatePrivilages to avoid errors for end users.

3. Try writing
your errors to SharePoint error logs (ULS Logs). Since it's a bad idea to
fill-up event log for your production environment.

4. Use SPQuery instead
of foreach loop while retrieving Items from the list.

5. Deploy
additional files used in your webpart to 12 hive. Use your solution package to
drop the files in 12 hive. Also, make sure that all the references (for e.g. Css
or .js files) get removed when the solution is retracted.
Also See : Best Practices to Improve Site Performance

Q.What is the main
difference between using SPListItem.Update() and

Ans. Using
SystemUpdate() will not create a new version and will also retain

See :
Part 1 Part

Related Posts :

The Tutorial of Sharepoint 2007 for beginners

Interview Questions and Answers of SharePoint 2007 for Administrator