Saturday, 8 March 2014

Accenture SharePoint Interview

Accenture SharePoint Interview
1. In C#, create a list that creates a notification (fires an event) whenever the list contents are changed. You may reuse any existing collection or .NET element. Focus on demonstrating notification not implementing all the list methods.
2. What is garbage collection?
Ans: garbage collecter is menory management in .net framework. It will remove unused manage objects from memory.
3. What is managed code and managed data?
Ans: the code which runs in CLR is managed code.The code which CLR can't understand that is unmanged code.
4. Can I use COM objects from a .NET Framework program? 
Ans: Yes, using com wraper class we can call COM objects.
5. Create an interface hierarchy for UI elements: TextBox, ListBox, ComboBox. Note, ComboBox “is-a” TextBox and a ListBox. Use UML and code.
Ans:
6. What is the output of the program:
using System;
class A
{
~A() {
Console.WriteLine("Destruct instance of A");
}
}
class B
{
object Ref;
public B(object o) {
Ref = o;
}
~B() {
Console.WriteLine("Destruct instance of B");
}
}
class Test
{
static void Main() {
B b = new B(new A());
b = null;
GC.Collect();
GC.WaitForPendingFinalizers();
}
}
Ans:Destruct instance of B
Destruct instance of A
7. Write a class declaration for class A and B. Class B inherits from A. Class A has-a integer element x and class B has-a integer element y. Show how you could print out the fields x or x and y depending on the class using the same “print” statement.
Ans) class Program
{
static void Main()
{
B b = new B();
b.printfromb();
}
}
public class A
{
public int x = 1;
}
class B : A
{
int y = 2;
public void printfromb()
{
Console.WriteLine("Print x" + x);
Console.WriteLine("Print x" + y);
}
}
8. Use the following class to create an Ellipse and Box class:
public abstract class Shape
{
public abstract void Paint(Graphics g);
}
Show how you would “paint”
Ans:
class Program
{
static void Main()
{
Graphics g;
Ellipse e = new Ellipse();
e.Paint(g);
Box b = new Box();
b.Paint(g);
}
}
public abstract class Shape
{
public abstract void Paint(Graphics g)
{
}
}
public class Box:Shape
{
public void Paint(Graphics g)
{
Console.WriteLine("Print x" + g);
}
}
class Ellipse : Shape
{
int y = 2;
public void Paint(Graphics g)
{
Console.WriteLine("Print x" + g);
}
}
9. Show how you would create a list programmatically in C# and SharePoint with your own custom code.
SPSite site = SPContext.Current.Site
SPWeb web = site.OpenWeb();
web.AllowUnsafeUpdates = true;
SPListTemplateCollection customListTemplates = site.GetCustomListTemplates(web);
SPListTemplate listTemplate = customListTemplates["listtemplatename"];
web.Lists.Add("User_Data", "A custom list to store user data", listTemplate)
web.Update();
10. Describe in point form how you would create your own event receiver in SharePoint.
iteam added, deleted, modefied.
11. Use C# and SharePoint API to demonstrate how you would assign permission levels to an existing group.
SPSite site = null;
SPWeb web = null;
site = new SPSite("http://server:100/sites/DevSite/");
web = site.OpenWeb();
SPRoleAssignment roleAssignment = new SPRoleAssignment("domain\\user","alias@domain.com","test","You!");
SPRoleDefinition roleDefinition = web.RoleDefinitions.GetByType(SPRoleType.Contributor);
roleAssignment.RoleDefinitionBindings.Add(roleDefinition);
web.RoleAssignments.Add(roleAssignment);
virtualization
web services
web application policy sharepoint 2010
sharepoint assign group permissions using object model code
web application policy sharepoint 2010.
What is .NET Reflection?
.NET Framework's Reflection API allows you to fetch type (assembly) information at runtime programmatically. We can also achieve late binding by using .NET Reflection. At runtime, the Reflection mechanism uses the PE file to read information about the assembly. Reflection enables you to use code that is not available at compile time. .NET Reflection allows an application to collect information about itself and also to manipulate on itself. It can be used effectively to find all types in an assembly and/or dynamically invoke methods in an assembly. This includes information about the type, properties, methods, and events of an object. With Reflection, we can dynamically create an instance of a type, bind the type to an existing object, or get the type from an existing object and invoke its methods or access its fields and properties. We can also access attribute information using Reflection.
Using Reflection, you can get any kind of information which you can see in a class viewer; for example, information on the methods, properties, fields, and events of an object