interface a
{
Method1()
Method2()
}
class b: a
{
override Method1()
override Method2()
}

what will happen & why?

Answer Posted / rajeev kumar

1.Method1() and Method2() are not having the ";" for termination .So it is a compile time error.

2.Method must have a return type.So it is a compile time error.

3.Method1() and Method2() must declare a body because it is not marked abstract, extern, or partial .
So it is a compile time error.
It should be like this:

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

namespace ConsoleApplication1
{
interface a
{
void Method1();
void Method2();
}

class b: a
{

public void Method1()
{
Console.WriteLine("From Method1()");
}
public void Method2()
{
Console.WriteLine("From Method2()");
}
}
class Program
{
static void Main(string[] args)
{
b obj=new b();
obj.Method1();
obj.Method2();

}
}
}

Output:
From Method1()
From Method2()

Is This Answer Correct ?    2 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is c# code is managed or unmanaged code?

646


Explain About a class access specifiers and method access specifiers.

732


Describe an interface class?

741


What standard types does c# use?

684


What is an enumerator in c#?

695






What debugging tools come with the .NET ssSDK?

932


What are the advantages of using c#?

682


What are the different approaches of passing parameters to a method?

694


Explain synchronous and asynchronous operations?

712


What is instantiating a class?

690


i want o/p 011242110 in c# code.

1837


Can an abstract class inherit from another abstract class c#?

704


What is inline function in c#?

691


Can we change static value in c#?

713


What is console writeline in c#?

638