Can we inherit an interface in an abstract class?

Answers were Sorted based on User's Feedback



Can we inherit an interface in an abstract class?..

Answer / sanjeev chaubey

Yes. you can

Is This Answer Correct ?    21 Yes 1 No

Can we inherit an interface in an abstract class?..

Answer / arne

yes you can. The example from anwser #4 is incorrect.

using System;

public interface IDisplay
{
void Display();
}

public abstract class MyClass : IDisplay
{

public MyClas(){};

public abstract DoSomething();

public void Display() {};
}

This code compiles fine without a problem. Abstract classes can inherit from interfaces as an abstract class defines the the functionality and restrictions for subclasses.

Is This Answer Correct ?    6 Yes 0 No

Can we inherit an interface in an abstract class?..

Answer / suyog

Yes ,We can

Is This Answer Correct ?    6 Yes 3 No

Can we inherit an interface in an abstract class?..

Answer / manish gobade

in order to run the above code we must impliment display() method of interface abs into class ba.

Is This Answer Correct ?    4 Yes 2 No

Can we inherit an interface in an abstract class?..

Answer / uma

no

Is This Answer Correct ?    5 Yes 6 No

Can we inherit an interface in an abstract class?..

Answer / sowmya

no we can't

using System;
interface abs
{
void display();
}
abstract class abs1:abs
{
public abstract void read();
}
class ba:abs1
{
int a;
public override void read()
{
Console.WriteLine("enter any value");
a=Convert.ToInt32(Console.ReadLine());
}
public void display()
{
Console.WriteLine(" Ur entered value:{0}",a);
}
}
class main
{
public static void Main()
{
ba b=new ba();
b.read();
b.display();
}
}
error CS0535: 'abs1' does not implement interface member
'abs.display()'

Is This Answer Correct ?    1 Yes 6 No

Post New Answer

More C Sharp Interview Questions

What is the use of tuple in c#?

0 Answers  


What is global namespace in c#?

0 Answers  


public void A() { int x; x = 8; x *= 4 + 8 / 2; } Given the above code, what is the value of "x"?

8 Answers  


What are primitive types in c#?

0 Answers  


Why is it a bad idea to throw your own exceptions?

4 Answers  






What is the major difference between a custom control and user control?

0 Answers   C DAC, CDAC,


What is scaffolding in c#?

0 Answers  


What is toint32 c#?

0 Answers  


What language do desktop applications use?

0 Answers  


Is enum a class c#?

0 Answers  


What is private class in c#?

0 Answers  


How to transpose rows into columns and columns into rows in a multi-dimensional array?

4 Answers   Microsoft,


Categories