?

Log in

Previous Entry | Next Entry

This question is taken from the .NET interview questions and answers book written by ShivprasadKoirala.


Take a look at following code samples.
Sample 1
classCustomer
   {
publicvoidMakeOrder()
       {
       }
voidCancelOrder()
       {
       }
   }
classGoldCustomer : Customer
   {
publicvoidGetDiscountOnOrder()
       {
       }
publicvoidReplaceOrder()
       {
       }
   }

Sample 2
interfaceIPerson
{
void Walk();
void Sit();
}

classCustomer : IPerson
{
publicvoid Walk()
   {
   }

publicvoid Sit()
   {
   }
}
classSupplier : IPerson
{
publicvoid Walk()
   {
   }

publicvoid Sit()
   {
   }
}

In First sample, Whatever Customer can doGold Customer can also do.  Gold customer has all the capability Customer had. These happened because one is derived from other. We say “Gold Customer is also a Customer”. And hence it is referred as “Is A” relationship.


Now let’s come to second example.
Interface IPerson declares what all things need to be there in them who implement is. Customer can walk and sit, also Supplier can walk and sit. It is possible because both of them implement IPerson interface. We say “Customer can do what was there in IPerson” and “Supplier can do what was there in the IPerson” And hence we call it as “Can a” relationship.

Below is a simple .NET interview question video with answer which explains Association , aggregation and composition.

Copy right www.questpond.com

Buy 600+ Real Time Interview Videos

Call +91-22-66752917 or mail us on questpond@questpond.com for more details on C#, .NET, ASP.NET, SQL Server interview question videos.

SQL Server interview question videos

Latest Month

March 2017
S M T W T F S
   1234
567891011
12131415161718
19202122232425
262728293031 

Tags

Powered by LiveJournal.com