Interviews - C# Corner

vinod jadhav
Can we inherit an abstract class from another abstract class?
By vinod jadhav in C# onApr 22 2019
  • Amol Bhillare
    May, 2019 24

    Yes, we can inherit the abstract class to another abstract class. See the below example-abstract class A{public virtual void show(){Console.WriteLine("Hello: Base Class!");}}abstract class B : A{public override void show(){Console.WriteLine("Hello: Derived Class!");}}

    • 4
  • Mahesh Alle
    Jul, 2019 22

    Yes, you can. See the below code.

    `public abstract class SavingAccountDetails
    {
    public abstract void PrintData();
    }

    public abstract class CurrentAccountDetails : SavingAccountDetails
    {
    public override void PrintData()
    {
    Console.WriteLine(“Current account details”);
    }
    }`

    • 1
  • Priyanka Singh
    Jul, 2019 22

    Sure, an abstract class can inherit from another class!!

    The only time a class cannot inherit from another is when the class you wish to inherit from is sealed or has private constructors only.

    • 1
  • Santosh Ingawale
    Jul, 2019 8

    Yes, You can inherit an abstract class from another abstract class.

    • 1
  • Om Pandit
    Jul, 2019 5

    Yes you can inherit abstract class from another abstract class.

    • 1
  • Manisankar Dixit
    May, 2019 15

    Yes you can inherit or extend one abstract class to another abstract class but if the class is a sealed class or single ton class at that time only inheritance cant be applicable.

    • 1
  • Shekhar Kumar
    Nov, 2019 26

    Yes, we can inherit an abstract class fron another abstract class.
    Code would be like:
    public abstract class ABS1
    {
    public abstract void Read();
    }
    public abstract class ABS2:ABS1
    {
    public abstract void Write();
    }
    public class AbsChild : ABS2
    {
    public override void Read()
    {
    throw new NotImplementedException();
    }

    1. public override void Write()
    2. {
    3. throw new NotImplementedException();
    4. }
    5. }

    • 0
  • Shekhar Kumar
    Oct, 2019 25

    yes, we can inherit an abstract class from another abstract class.
    note: An abstract class cannot be instanciated.

    • 0
  • Cindy Nelson
    Sep, 2019 9

    no

    • 0
  • Bidyasagar Mishra
    Aug, 2019 4

    yes, you can

    • 0
  • Mahesh Pola
    Jul, 2019 5

    • 0
  • Deepak Rajput
    Jun, 2019 22

    no

    • 0

Most Popular Companies

Most Popular Job Functions

MOST LIKED QUESTIONS