If a class IA is implementing an interface I which is having a method a, then
can is the following allowed? Will that have all the methods of IA apart from that of interface I?
I a = new IA();
Yes. always the base class or interface can contain derived class, but it will have
only those of the base. So it will not have members of IA which are not from interface I.
using System;
using System.Collections.Generic;
using System.Text;
namespace OOPTest6
{
interface I
{
void a();
}
class IA : I
{
public void a()
{
Console.Out.Write("a");
}
public void nonintfacemeth()
{
Console.Out.Write("nonintfacemeth");
}
}
class Program
{
static void Main(string[] args)
{
I i = new IA();
i.a();
}
}
}
Subscribe to:
Post Comments (Atom)
0 comments
Post a Comment