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
What are the Types of assemblies that can be created in dotnet
Is a games console a computer?
What are managed providers?
What is interface inheritance in c#?
What is a web service in c#?
What is literal in c#?
How to transpose multi-dimensional array?
What is Named parameter in C#?
how to insert the data from the grid view to database table though button click.pls send the answer to mail id suri1319@gmail.com
Can we have only “try” block without “catch” block in c#?
What is ilasm.exe used for?
Why are mutable structs evil?
Why do I get a syntax error when trying to declare a variable called checked?
What is the use of 'using' statement in c#?
Is overriding of a function possible in the same class?