Sunday, January 2, 2022

 Q1. What is WCF? 

WCF stands for Windows Communication Foundation. It is a Software development kit for developing services on Windows. WCF is introduced in .NET 3.0. in the System.ServiceModel namespace. WCF is based on basic concepts of Service oriented architecture (SOA) 
 
Q2. What is endpoint in WCF service? 
The endpoint is an Interface which defines how a client will communicate with the service. It consists of three main points: Address, Binding and Contract. 
 
Q3. Explain Address, Binding, and contract for a WCF Service? 
Address: Address defines where the service resides. 
Binding: Binding defines how to communicate with the service. 
Contract: Contract defines what is done by the service. 
 
Q4. What is the various address format in WCF? 
a) HTTP Address Format: --> http://localhost: 
b) TCP Address Format: --> net.tcp://localhost: 
c) MSMQ Address Format: --> net.msmq://localhost: 
 
Q5. What are the types of binding available in WCF? 
A binding is identified by the transport it supports and the encoding it uses. Transport may be HTTP, TCP etc. and encoding may be text, binary etc. The popular types of binding may be as below: 
a) BasicHttpBinding 
b) NetTcpBinding 
c) WSHttpBinding 
d) NetMsmqBinding 
 
Q6. What are the types of contract available in WCF? 
The main contracts are: 
a) Service Contract: Describes what operations the client can perform. 
b) Operation Contract: defines the method inside Interface of Service. 
c) Data Contract: Defines what data types are passed 
d) Message Contract: Defines whether a service can interact directly with messages 
 
Q7. What are the various ways of hosting a WCF Service? 
a) IIS b) Self Hosting c) WAS (Windows Activation Service) 
 
Q8. What is the proxy for WCF Service? 
A proxy is a class by which a service client can Interact with the service. 
Using proxy in the client application we are able to call the different methods exposed by the service 
 
 
Q9. How can we create Proxy for the WCF Service? 
We can create proxy using the tool svcutil.exe after creating the service. 
We can use the following command at command line. 
svcutil.exe *.wsdl *.xsd /language:C# /out:SampleProxy.cs /config:app.config 
 
Q10.What is the difference between WCF Service and Web Service? 
a) WCF Service supports both http and TCP protocol while webservice supports only http protocol. 
b) WCF Service is more flexible than web service. 
 
Q11.What is Data Contract and Service Contract? Explain  
Data represented by creating Data Contract which expose the 
data which will be transferred /consumed from the service 
to its clients. 
 
**Operations which is the functions provided by this 
service. 
 
To write an operation on WCF, you must write it as an 
interface, this interface contains the "Signature" of the 
methods tagged by ServiceContract attribute, and all methods 
signature will be implemented on this interface tagged with 
OperationContract attribute. 
 
and to implement these service contract you must create 
a class which implement the interface and the actual 
implementation will be on that class. 
 
 
Code Below show How to create a Service Contract: 

Code: 

[ServiceContract] 
Public Interface IEmpOperations 

[OperationContract] 
Decimal Get EmpSal(int EmpId); 
 

 
Class MyEmp: IEmpOperations 

Decimal Get EmpSal() 

// Implementation of this method. 

 

Tuesday, May 29, 2012

SharePoint 2010 Questions And Answers


SharePoint Architecture Questions

1) What are Web Applications in SharePoint?
An IIS Web site created and used by SharePoint 2010. Saying an IIS virtual server is also an acceptable answer.

2) What is an application pool?
A group of one or more URLs that are served by a particular worker process or set of worker processes.

3) Why are application pools important?
They provide a way for multiple sites to run on the same server but still have their own worker processes and identity.

4) What are Web Application Policies?
Enables security policy for users at the Web application level, rather than at the site collection or site level. Importantly, they override all other security settings.


5) What are zones?
Different logical paths (URLs meaning) of gaining access to the same SharePoint Web application.

6) What is a site collection?
 A site collection contains a top-level website and can contain one or more sub-sites web sites that have the same owner and share administration settings.

7) What are content databases?
A content database can hold all the content for one or more site collections.

8) What is a site?
 A site in SharePoint contains Web pages and related assets such as lists, all hosted within a site collection.

9) What are My Sites?
Specialized SharePoint sites personalized and targeted for each user.

10) What is the difference between Classic mode authentication and Claims-based authentication?
As the name implies, classic authentication supports NT authentication types like Kerberos, NTLM, Basic, Digest, and anonymous. Claims based authentication uses claims identities against a against a trusted identity provider.

11) When would you use claims, and when would you use classic?
Classic is more commonly seen in upgraded 2007 environments whereas claims are the recommended path for new deployments.

12) Describe the potential components for both a single server, and multiple servers, potentially several tiered farms:
A single-server SharePoint Server 2010 environment leverages a built-in SQL Server 2008 Express database. The problems with this environment is scalability, not being able to install the with built-in database on a domain controller, the database cannot be larger than 4 GB, and you cannot use User Profile Synchronization in a single server with built-in database installation.
An example of a multiple tier farm would be a three-tier topology, considered one of the more efficient physical and logical layouts to supports scaling out or scaling up and provides better distribution of services across the member servers of the farm. This is considered a good architecture since one can add Web servers to the Web tier, add app servers to the application tier, and add database servers to the database tier.

SharePoint Backup and Restore Questions

13) What are some of the tools that can be used when backing up a SharePoint 2010 environment?
  • SharePoint farm backup and recovery
  • SQL Server
  • System Center Data Protection Manager
14) What Microsoft tool can be used for incremental backups?
System Center Data Protection Manager

Managed Metadata Questions

15) What is Managed Metadata?
Managed metadata is a hierarchical collection of centrally managed terms that you can define, and then use as attributes for items.

16) What are Terms and Term Sets?
A term is a word or a phrase that can be associated with an item.  A term set is a collection of related terms.

17) How do Terms And Term Sets relate to Managed Metadata?
Managed metadata is a way of referring to the fact that terms and term sets can be created and managed independently from the columns themselves.

18) Are there different types of Term Sets?
There are Local Term Sets and Global Term Sets, one created within the context of a site collection and the other created outside the context of a site collection, respectively.

19) How are terms created and used?
There are several ways; however the most common is to use the Term Store Management Tool.

20) How is Managed Metadata, and the related Term technology used?
Through the UI, the most common use is through the managed metadata list column which allows you to specify the term set to use. It also related to searching and enhancing the user search experience.

Sandbox Solutions Questions

21) What is a sandboxed solution?
Components that are deployed to run within the sandboxed process rather than running in the production Internet Information Services (IIS) worker process.

22) What are some examples of things that might run within the SharePoint sandbox?
Any of the following are acceptable answers:
 Web Parts
Event receivers
Feature receivers
Custom Microsoft SharePoint Designer workflow activities
Microsoft InfoPath business logic
others….

23) Why are sandboxed solutions used?
Primarily because they promote high layers of isolation. By default they run within a rights-restricted, isolated process based around Code Access Security (CAS). Isolation is possible to increase with activities like running the sandboxing service on only specific SharePoint 2010 servers.

SharePoint Search Questions

24) What is a content source in relation to SharePoint search? What’s the minimum amount of content sources?
A content source is a set of options that you can use to specify what type of content is crawled, what URLs to crawl, and how deep and when to crawl. You must create at least one content source before a crawl can occur.

25) What is a search scope?
A search scope defines a subset of information in the search index. Users can select a search scope when performing a search.

26) What is a federated location with SharePoint search?
Federated locations provide information that exists outside of your internal network to your end-users.

27) How does managed metadata affect search?
Enhances the end-user search experience by mapping crawled properties to managed properties. Managed properties show up in search results and help users perform more successful queries.

28)  What is query logging in SharePoint 2010?
Collects information about user search queries and search results that users select on their computers to improve the relevancy of search results and to improve query suggestions.

29) What authentication type does the SharePoint crawler use?
The crawl component requires access to content using NTLM authentication.

Services Architecture Questions

30) Please describe what a Service Application is in SharePoint 2010.
Service applications in SharePoint 2010 are a set of services that can possibly be shared across Web applications. Some of these services may or may not be shared across the SharePoint 2010 farm. The reason these applications are shared is the overall reduction of resources required to supply the functionality these services cultivate.

31) Please provide an example of one of these service applications.
Any of the below are acceptable answers:
Access Services
Business Data Connectivity service
Excel Services Application
Managed Metadata service
PerformancePoint Service Application
Search service
Secure Store Service
State service
Usage and Health Data Collection service
User Profile service
Visio Graphics Service
Web Analytics service
Word Automation Services
Microsoft SharePoint Foundation Subscription Settings Service

32) What are Service Application Groups used for?
Just provides a logical grouping of services that are scoped to a particular Web Application.

33) How are Service Applications deployed in terms of IIS (Internet Information Services)?
They are provisioned as a single Internet Information Services (IIS) Web site.

34) Explain how connections are managed with Service Applications.
A virtual entity is used that is referred to as a proxy, due to label in PowerShell.

35) What are some common examples of SharePoint 2010 services architectures, and what are the advantages of each design?
The three most popular designs are single farms with either a single service application group or multiple service application groups, or Enterprise services farms.
Single farms with a single service application group are generally the most common, and have the advantages of easy deployment, simple service application allocation, effective resource utilization and cohesive management.
Single farms with multiple service application groups is less common, and have the advantage of potential individual management of service applications as well as allowing data isolation, and while being more complex to deploy and maintain allows targeting of sites to particular service applications.
Enterprise Service Farms is pretty uncommon as it is a complete farm dedicated to Service Applications but promotes autonomous management and high levels of data isolation.

36) Are there any other type of relevant service architectures?
Depending on the environment requirements, a specialized farm can also be used in order to deploy specific services tailored to the organizational requirements which can aid in scaling out and conservation of resources.

37) What is the User Profile service?
Allows configuring and managing User profile properties, Audiences, Profile synchronization settings, organization browsing and management settings, and My Site settings.

38) What are User Profiles?
Aggregates properties from diverse identity content sources together to create unified and consistent profiles across an organization, used throughout the SharePoint environment.

39) What is Excel Services?
Allows sharing, securing, managing, and using Excel 2010 workbooks in a SharePoint Server Web site or document library. Excel Services consists of the Excel Calculation Services (ECS), Microsoft Excel Web Access (EWA), and Excel Web Services (EWS) components.

40) What is PerformancePoint Services?
Allows users to monitor and analyze a business by building dashboards, scorecards, and key performance indicators (KPIs).

41) What is Visio Services?
Allows users to share and view Microsoft Visio Web drawings. The service also enables data-connected Microsoft Visio 2010 Web drawings to be refreshed and updated from various data sources.

42) What is Access Services?
Allows users to edit, update, and create linked Microsoft Access 2010 databases that can be viewed and manipulated by using an internet browser, the Access client, or a linked HTML page.

43) What is the Secure Store Service (SSS)?
A secure database for storing credentials that are associated with application IDs

44) What is Content Deployment?
Content deployment enables you to copy content from a source site collection to a destination site collection.

Backup / DR Questions
45) Describe how redundancy can be built into a SharePoint environment. Please be specific in regards to any auxiliary components.

Multiple front-end web servers (WFE’s) can be deployed and correlated through Windows NLB or anything approach. Application servers can be deployed into the farm for a variety of purposes, depending on organizational requirements. Databases can be clustered or mirrored, again depending on requirements and environment.

46) From a basic standpoint, what is the difference between SQL clustering and mirroring?
Clustering provides a failover scenario whereby one or more nodes can be swapped as active depending on whether a node goes down. In mirroring, transactions are sent directly from a principal database and server to a mirror database to establish essentially a replica of the database.

Governance Questions

47) What Is Governance in terms of SharePoint 2010?
Governance is the set of policies, roles, responsibilities, and processes that guide, direct, and control how an organization’s business divisions and IT teams cooperate to achieve business goals.

48) What are some useful, OOB features of SharePoint that aid with governance of an environment?
Any of the below are acceptable answers. There are some others but these are the major ones that I generally look for from a candidate:
Site templates – consistent branding, site structure, and layout can be enforce a set of customizations that are applied to a site definition.
Quotas – limits to the amount of storage a site collection can use.
Locks - prevent users from either adding content to a site collection or using the site collection.
Web application permissions and policies – comprehensive security settings that apply to all users and groups for all site collections within a Web application.
Self-service site creation - enables users to create their own site collections, thus must be incorporated into a governance scheme.

Monitoring Questions

49) Describe the monitoring features that are baked into SharePoint 2010.
Diagnostic logging captures data about the state of the system, whereas health and usage data collection uses specific timer jobs to perform monitoring tasks, collecting information about:
  • Performance Counter Fata
  • Event Log Data
  • Timer Service Data
  • Metrics For Site Collections and Sites
  • Search Usage Data
General Workflow Questions

50) What is a declarative workflow? Can non-authenticated users participate in workflows?
Workflows created by using Microsoft SharePoint Designer 2010, the default setting enables deployment of declarative workflows. Yes, however you do not give non-authorized users access to the site. The e-mail message and attachments sent from notifications might contain sensitive information.


Friday, May 25, 2012

C# .Net Interview Questions


        1. Which is better - singly linked list or doubly linked list? What are the pros and cons of using each?
Answer -
 It depends on the requirement.Single linked list has smaller memory requirement because it needs only forward reference. If you need to get next item from a specified item, then you should use single list. It can be traversed in forward direction only.

When you need to get previous or next item from a specified item then doubly linked is the best option. It can be traversed in both directions.

2. What's the difference between Managed code and Native code? 
Answer - 
Managed Code - Managed code is the code which runs under .Net CLR.  CLR basically take care of Exception handling, memory management, Code access security, etc.  It is not compiled directly to machine code , but to an intermediate language.  

Native code: Code which is complied directly to machine code. It is executed by OS directly. It always has chances of memory leak if developer has not handled it properly. Unlike CLR, There is no garbage collection and no memory management.

       3. What is thread safe code?
Answer -
In multithreaded application where multiple threads call the same method of the object. Then there should be synchronization mechanism so that one thread can not interrupt other thread. If this situation is not synchronized, then one thread might interrupt another thread and the object could be left in an invalid state. A class whose members are protected from such interruptions is called thread-safe.



C# Interview Questions & Answers


Question 1:  Write a function that receives three integer inputs for the lengths of the sides of a triangle and returns one of four values to determine the triangle type (1=scalene, 2=isosceles, 3=equilateral, 4=error). Generate test cases for the function assuming another developer coded the function.

Answer : 

int GetCubicType(int Height, int Width, int Length)
    {
        if (Height < 0 || Width < 0 || Length < 0)
            return 4;
        else
        {
            if ((Height == Width) && (Height == Length))

                return 3;
            else
                if ((Height == Width) || (Width == Length) || (Length == Width))

                    return 2;
                else
                    return 1;
        }
   }


Question 2: Implement a circular queue of integers of user-specified size using a simple array. Provide routines to initialize(), enqueue() and dequeue() the queue. Make it thread safe.

Answer :

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ThreadSafeCirculurQueue
{
    class ThreadSafeCircularQueue
    {
        private int[] _queue;
        private int _length;
        private int _head;
        private int _tail;

        private static object _objLocker = new object();

        public ThreadSafeCircularQueue()
        {
            Initialize();
        }

        private void Initialize()
        {
            _head = -1;
            _tail = -1;

            Console.Write("Please enter queue size: ");

            string length = Console.ReadLine();

            int queueLength = 0;

            bool success = int.TryParse(length, out queueLength);

            if(!success){
                Console.Write("Invalid Data\n PleaseTry Again");
                return;
            }

            _length = queueLength;

            _queue = new int[_length];
        }

        private void Enqueue(int data)
        {
            lock (_objLocker)
            {
                if ((_head == 0 && _tail == _length - 1) || 
                   (_tail + 1 == _head))
                {
                    Console.WriteLine("Queue is full.");
                    return;
                }
                else
                {
                    if (_tail == _length - 1)
                        _tail = 0;
                    else
                        _tail++;

                    _queue[_tail] = data;

                    Console.WriteLine("Inserted Item  --> {0}", data);
                }

                if (_head == -1)
                    _head = 0;
            }
        }

        private void Dequeue()
        {
            lock (_objLocker)
            {
                int data;
                if (_head == -1)
                {
                    Console.WriteLine("Queue is empty.");
                    data = -1;
                }
                else
                {
                    data = _queue[_head];
                    _queue[_head] = 0;

                    if (_head == _tail)
                        _head = _tail = -1;
                    else
                        if (_head == _length - 1)
                            _head = 0;
                        else
                            _head++;

                    Console.WriteLine("Removed Item --> {0}", data);
                }
                
            }
        }

        private void ShowData()
        {
            lock (_objLocker)
            {
                int i;
                if (_head == -1)
                {
                    Console.WriteLine("Queue is empty.");
                    return;
                }
                else
                {
                    if (_tail < _head)
                    {
                        for (i = 0; i <= _length - 1; i++)
                            Console.Write("{0} ", _queue[i]);
                    }
                    else
                    {
                        for (i = 0; i <= _tail; i++)
                            Console.Write("{0} ", _queue[i]);
                    }
                    Console.WriteLine();
                }
            }
        }

        public void EnqueueDequeue()
        {
            for (int i = 1; i < 5; i++)
            {
                Enqueue(i);
            }
            ShowData();
            Enqueue(5); // Circular queue is full!
            for(int i = 1; i <5;i++)
            {
                Dequeue();
            }

            Dequeue(); // Circular queue is empty!
            ShowData();

            Enqueue(6);
            ShowData();
            Enqueue(7);
            ShowData();
            Dequeue();
            Dequeue();
            Enqueue(8);
            ShowData();
            Enqueue(9);
            ShowData();
            Enqueue(10);
            ShowData();
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            ThreadSafeCircularQueue circularQueue = 
                         new ThreadSafeCircularQueue();

            Thread[] threads = new Thread[1]; // Thread can be increased

            for (int i = 0; i < threads.Length; i++)
            {
                threads[i] = 
                new Thread(new ThreadStart(circularQueue.EnqueueDequeue));
            }

            for (int i = 0; i < threads.Length; i++)
            {
                threads[i].Start();
            }

            Console.ReadLine();
        }
    }
  
}