ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip       Ask Questions on ANYTHING, that arise in your Daily Life at     FORUM9.COM
Google
 
Categories  >>  Software  >>  Microsoft Related  >>  Dot Net  >>  Dot Net General
 
 


 

 
 Dot Net Framework interview questions  Dot Net Framework Interview Questions
 Dot Net Remoting interview questions  Dot Net Remoting Interview Questions
 Dot Net WindowsForms interview questions  Dot Net WindowsForms Interview Questions
 Dot Net General interview questions  Dot Net General Interview Questions
 Dot Net AllOther interview questions  Dot Net AllOther Interview Questions
Question
What is a strategy pattern? Implement it.
 Question Submitted By :: Guest
I also faced this Question!!     Rank Answer Posted By  
 
  Re: What is a strategy pattern? Implement it.
Answer
# 1
Strategy pattern is one of the 23 design patterns 
available. The basic concept of strategy pattern is object 
composition at runtime. When you have multiple classes each 
having similar behaviour but the behaviour could change 
based on an external factor or the object itself. For 
example take a car, a car can have an engine, a steering 
wheel, 4 tyres e.t.c but a remote control car will not have 
an engine but will have the other characteristics of a 
normal car. For this case let us have the following code:
Interface HasEngine
{
void Engine();
}
Interface Tyres
{
void 4Tyres();
}

class Hummer:HasEngine,Tyres
{
override void Engine()
{
Console.WriteLine("Has Engine");
}
override void 4Tyres()
{
Console.WriteLine("Has 4 tyres");
}
}
class RemoteCar:HasEngine,Tyres
{
override void Engine()
{
Console.WriteLine("Has no Engine");
}
override void 4Tyres()
{
Console.WriteLine("Has 4 tyres");
}
}
class Car
{
HasEngine HE;
Tyres T;
setEngine(HasEngine obj)
{
HE=obj;
}
setTyres(Tyres obj)
{
T=obj;
} 
}
class MainClass:Car
{
HasEngine he;
Tyres  tyr;
setInstance()
{
he = new Hummer();
tyr = new Hummer();
}
public static void Main()
{
MainClass mc = new Car();
mc.setInstance();
mc.setEngine(he);
mc.setTyres(tyr);
}
}
 
Is This Answer Correct ?    1 Yes 0 No
Guest
 

 
 
 
Other Dot Net General Interview Questions
 
  Question Asked @ Answers
 
What?s a Windows process?  1
what is a strong name?  3
How WSDL is stored ? TCS1
How to find methods of a assembly file (not using ILDASM) Reflection  1
What is a Strong Name?  1
What is prerender event of a page? C-Squared-Systems3
What is CLR, CLS,CTS Deloitte2
Is string a value type or a reference type?  1
can any one tel me hw to connect database connectivity of dot NET and back end as MS access?  1
Can you configure a .NET Remoting object via XML file?  1
What is the model role in Mvc architecture?  3
What is Delegate? Have ever used Delegates in your project. Deloitte1
why do you want to join deloitte, where do you exactly fit in. Deloitte1
is c#.net supports multiple inheritance?  9
What is RunTime Polymorphism? Deloitte2
What is a system lock? Wipro2
What is a strategy pattern? Implement it.  1
What is the standard you use to wrap up a call to a Web service  1
1.What is the major advantage of polymorphism? Please don't simply say binding. Specify any other reason. 247Customer1
How do you start, pause, continue or stop a Windows service off the command line?  1
 
For more Dot Net General Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com