Anjali Khan

Anjali Khan

  • NA
  • 867
  • 226.1k

what is the ans for the below objective type qus in mvc?

Sep 14 2017 3:47 AM
Hi Frnds
 
A)what is the ans for the below qus 
 
1.
what will be the output of the following program?
[serviceContract()]
public interface ImyService
{
[OperationContract]
int MyMethod();
}
[ServiceBehavior(InstanceContectMode=InstanceContectMode.PerSession)]
public class myservice:IMyService
{
static int m_counter=0;
public int MyMethod()
{
m_Counter++;
return m_counter;
}
}
 
 
output -
1 Counter:1
Counter:2
Counter:3
Counter:4
2 Counter: 1
Counter: 1
Counter: 1
Counter: 1
3 Counter: 0
Counter: 1
Counter: 2
Counter: 3
4 Compilation error in services
 
 
B)
what will be the output of the following program?
public class myservice:IMyService
{
static int m_counter=0;
public int MyMethod()
{
m_Counter++;
return m_counter;
}
}
static void main(string() args[])
{
MyCalculatorServicesProxy.MyServiceProxy proxy = new MyCalculatorServicesProxy.MyServiceProxy();
Console.wrileline("Counter: " + Proxy.MyMethod());
Console.wrileline("Counter: " + Proxy.MyMethod());
Console.wrileline("Counter: " + Proxy.MyMethod());
Console.wrileline("Counter: " + Proxy.MyMethod());
Console.ReadLine();
}
output
;
1 Counter:1
Counter:2
Counter:3
Counter:4
2 Counter: 1
Counter: 1
Counter: 1
Counter: 1
3 Counter: 0
Counter: 1
Counter: 2
Counter: 3
4 Compilation error in services
 

Answers (1)