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
Define acid rule of thumb for transactions in c#.
Explain the Different types of configuration files in .net?
What is gac? How to put assembly in gac?
What are value types and reference types?
What is the difference between Java and .NET garbage collectors?
Is c# code is unmanaged or managed code?
What is constructors, explain with syntax
Can we customize the serialization process?
How many parameters can a method have c#?
What is a c# delegate?
What is the difference between interface and abstract class in c#?
How a two-dimensional array declared in C#?
What is the difference between finalize() and dispose() methods?
Explain about Threading Types.
Can abstract class have constructor c#?