Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

What do you mean by stack and heap in c#?

860


What is foreach loop in c#?

907


Explain About ADO and its objects

951


what class is underneath the sortedlist class?

894


What is clr namespace?

925


Why array is faster than arraylist in c#?

939


Can a loop recorder detect a heart attack?

959


What is connection pooling in ado.net?

889


Define a class and an object?

917


What is dbml file in c#?

945


What is integer c#?

854


How to put assembly in gac?

861


How does insertion sort work?

866


Which is better interface or abstract class in c#?

762


Explain the use of virtual, sealed, override, and abstract method?

829